Skip to content

Commit

Permalink
🐛 Don't show archived questionnaires for all apps/archetypes (#1566)
Browse files Browse the repository at this point in the history
Resolves https://issues.redhat.com/browse/MTA-1722

Signed-off-by: ibolton336 <ibolton@redhat.com>
  • Loading branch information
ibolton336 authored Nov 22, 2023
1 parent a71d419 commit bac9ebe
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 bac9ebe

Please sign in to comment.