Skip to content

Commit

Permalink
🐛 Don't show archived questionnaires for all apps/archetypes
Browse files Browse the repository at this point in the history
Signed-off-by: ibolton336 <[email protected]>
  • Loading branch information
ibolton336 committed Nov 22, 2023
1 parent 6e9f95b commit ecf3d09
Showing 1 changed file with 28 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,23 @@ const AssessmentActionsTable: React.FC<AssessmentActionsTableProps> = ({
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 (
<>
<QuestionnairesTable
Expand All @@ -34,16 +51,17 @@ const AssessmentActionsTable: React.FC<AssessmentActionsTableProps> = ({
isFetching={isFetchingQuestionnaires || isFetchingAssessmentsById}
tableName="Required questionnaires"
/>

<QuestionnairesTable
application={application}
archetype={archetype}
isReadonly
questionnaires={archivedQuestionnaires}
assessments={assessments}
isFetching={isFetchingQuestionnaires || isFetchingAssessmentsById}
tableName="Archived questionnaires"
/>
{filteredArchivedAssessments.length === 0 ? null : (
<QuestionnairesTable
application={application}
archetype={archetype}
isReadonly
questionnaires={archivedQuestionnaires}
assessments={filteredArchivedAssessments}
isFetching={isFetchingQuestionnaires || isFetchingAssessmentsById}
tableName="Archived questionnaires"
/>
)}
</>
);
};
Expand Down

0 comments on commit ecf3d09

Please sign in to comment.