From ecf3d0912ec963ff18218e7de16d6ff4d2741421 Mon Sep 17 00:00:00 2001 From: ibolton336 Date: Wed, 22 Nov 2023 10:10:17 -0500 Subject: [PATCH] :bug: Don't show archived questionnaires for all apps/archetypes Signed-off-by: ibolton336 --- .../components/assessment-actions-table.tsx | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/client/src/app/pages/assessment/components/assessment-actions/components/assessment-actions-table.tsx b/client/src/app/pages/assessment/components/assessment-actions/components/assessment-actions-table.tsx index eb40ab7f79..9ef0175551 100644 --- a/client/src/app/pages/assessment/components/assessment-actions/components/assessment-actions-table.tsx +++ b/client/src/app/pages/assessment/components/assessment-actions/components/assessment-actions-table.tsx @@ -24,6 +24,23 @@ const AssessmentActionsTable: React.FC = ({ const archivedQuestionnaires = questionnaires.filter( (questionnaire) => !questionnaire.required ); + + const nonRequiredQuestionnaireIds = questionnaires + .filter((q) => !q.required) + .map((q) => q.id); + + const relevantAssessmentIds = ( + application?.assessments || + archetype?.assessments || + [] + ).map((a) => a.id); + + const filteredArchivedAssessments = assessments.filter( + (assessment) => + nonRequiredQuestionnaireIds.includes(assessment.questionnaire.id) && + relevantAssessmentIds.includes(assessment.id) + ); + return ( <> = ({ isFetching={isFetchingQuestionnaires || isFetchingAssessmentsById} tableName="Required questionnaires" /> - - + {filteredArchivedAssessments.length === 0 ? null : ( + + )} ); };