From a78bc2838e2b8439d6fc7dbfa8294cd24dc41b65 Mon Sep 17 00:00:00 2001 From: Ian Bolton Date: Thu, 12 Oct 2023 20:08:29 +0000 Subject: [PATCH] :bug: determine assessment status from all assessments (#1474) https://issues.redhat.com/browse/MTA-1391 Signed-off-by: ibolton336 --- .../applications-table-assessment.tsx | 2 +- .../application-assessment-status.tsx | 52 +++++++++---------- 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/client/src/app/pages/applications/applications-table-assessment/applications-table-assessment.tsx b/client/src/app/pages/applications/applications-table-assessment/applications-table-assessment.tsx index 04874ac4ae..339d5a8ce9 100644 --- a/client/src/app/pages/applications/applications-table-assessment/applications-table-assessment.tsx +++ b/client/src/app/pages/applications/applications-table-assessment/applications-table-assessment.tsx @@ -655,7 +655,7 @@ export const ApplicationsTable: React.FC = () => { {...getTdProps({ columnKey: "assessment" })} > { - switch (assessment.status) { - case "empty": - return "NotStarted"; - case "started": - return "InProgress"; - case "complete": - return "Completed"; - default: - return "NotStarted"; - } -}; - export const ApplicationAssessmentStatus: React.FC< ApplicationAssessmentStatusProps -> = ({ assessments, isLoading = false, fetchError = null }) => { +> = ({ application, isLoading = false }) => { const { t } = useTranslation(); - //TODO: remove this once we have a proper assessment status - const { assessment } = useFetchAssessmentById(assessments?.[0]?.id); + + const { + assessments, + isFetching: isFetchingAssessmentsById, + fetchError, + } = useFetchAssessmentsByItemId(false, application.id); + + if (application?.assessed) { + return ; + } if (fetchError) { return ; } - if (isLoading) { + + if (isLoading || isFetchingAssessmentsById) { return ; } - return assessment ? ( - - ) : ( - - ); + if ( + assessments?.some((a) => a.status === "started" || a.status === "complete") + ) { + return ; + } + + return ; };