From bac9ebead9141b6adad96fb30ac89630de11f4e9 Mon Sep 17 00:00:00 2001 From: Ian Bolton Date: Wed, 22 Nov 2023 16:19:25 -0500 Subject: [PATCH] :bug: Don't show archived questionnaires for all apps/archetypes (#1566) Resolves https://issues.redhat.com/browse/MTA-1722 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 : ( + + )} ); };