From d13aec75f11bc357d7c1531b656af8ca2135506b Mon Sep 17 00:00:00 2001 From: andreas-unleash Date: Wed, 4 Oct 2023 15:11:07 +0300 Subject: [PATCH] fix: ReportTable not updating status dynamically (#4923) Fixes a bug with the UI where featureType comparison was using name instead of id --------- Signed-off-by: andreas-unleash --- .../ReportExpiredCell/formatExpiredAt.ts | 2 +- .../ReportStatusCell/formatStatus.ts | 3 +- .../ProjectHealth/ReportTable/ReportTable.tsx | 28 +++++++++---------- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/frontend/src/component/project/Project/ProjectHealth/ReportTable/ReportExpiredCell/formatExpiredAt.ts b/frontend/src/component/project/Project/ProjectHealth/ReportTable/ReportExpiredCell/formatExpiredAt.ts index c8afc7c9b6..93264fd17d 100644 --- a/frontend/src/component/project/Project/ProjectHealth/ReportTable/ReportExpiredCell/formatExpiredAt.ts +++ b/frontend/src/component/project/Project/ProjectHealth/ReportTable/ReportExpiredCell/formatExpiredAt.ts @@ -11,7 +11,7 @@ export const formatExpiredAt = ( const { type, createdAt } = feature; const featureType = featureTypes.find( - featureType => featureType.name === type + featureType => featureType.id === type ); if ( diff --git a/frontend/src/component/project/Project/ProjectHealth/ReportTable/ReportStatusCell/formatStatus.ts b/frontend/src/component/project/Project/ProjectHealth/ReportTable/ReportStatusCell/formatStatus.ts index 65e595832e..9e8a48193f 100644 --- a/frontend/src/component/project/Project/ProjectHealth/ReportTable/ReportStatusCell/formatStatus.ts +++ b/frontend/src/component/project/Project/ProjectHealth/ReportTable/ReportStatusCell/formatStatus.ts @@ -13,12 +13,11 @@ export const formatStatus = ( const { type, createdAt } = feature; const featureType = featureTypes.find( - featureType => featureType.name === type + featureType => featureType.id === type ); const date = parseISO(createdAt); const now = new Date(); const diff = getDiffInDays(date, now); - if ( featureType && expired(diff, featureType) && diff --git a/frontend/src/component/project/Project/ProjectHealth/ReportTable/ReportTable.tsx b/frontend/src/component/project/Project/ProjectHealth/ReportTable/ReportTable.tsx index 44fc22ff5f..98f393a360 100644 --- a/frontend/src/component/project/Project/ProjectHealth/ReportTable/ReportTable.tsx +++ b/frontend/src/component/project/Project/ProjectHealth/ReportTable/ReportTable.tsx @@ -59,21 +59,19 @@ export const ReportTable = ({ projectId, features }: IReportTableProps) => { ); const { featureTypes } = useFeatureTypes(); - const data: IReportTableRow[] = useMemo( - () => - features.map(report => ({ - project: projectId, - name: report.name, - type: report.type, - stale: report.stale, - environments: report.environments, - status: formatStatus(report, featureTypes), - lastSeenAt: report.lastSeenAt, - createdAt: report.createdAt, - expiredAt: formatExpiredAt(report, featureTypes), - })), - [projectId, features] - ); + const data: IReportTableRow[] = useMemo(() => { + return features.map(report => ({ + project: projectId, + name: report.name, + type: report.type, + stale: report.stale, + environments: report.environments, + status: formatStatus(report, featureTypes), + lastSeenAt: report.lastSeenAt, + createdAt: report.createdAt, + expiredAt: formatExpiredAt(report, featureTypes), + })); + }, [projectId, features, featureTypes]); const initialState = useMemo( () => ({