From 4bd5a21117cfc08485ccff69bba7f9db4a83105d Mon Sep 17 00:00:00 2001 From: Gilles Dubreuil Date: Tue, 19 Sep 2023 22:10:35 +0200 Subject: [PATCH] Reduce assessment list to unique questionnaires Signed-off-by: Gilles Dubreuil --- client/src/app/api/models.ts | 5 ----- .../pages/reports/components/landscape/donut.tsx | 3 +++ .../reports/components/landscape/landscape.tsx | 4 ++++ client/src/app/pages/reports/reports.tsx | 16 ++++++++++------ 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/client/src/app/api/models.ts b/client/src/app/api/models.ts index b9524cc588..eb2cf9c9df 100644 --- a/client/src/app/api/models.ts +++ b/client/src/app/api/models.ts @@ -720,11 +720,6 @@ export interface AssessmentRisk { applicationId: number; risk: Risk; } -export interface AssessmentRisk { - assessmentId: number; - applicationId: number; - risk: Risk; -} export interface AssessmentQuestionRisk { category: string; diff --git a/client/src/app/pages/reports/components/landscape/donut.tsx b/client/src/app/pages/reports/components/landscape/donut.tsx index 5dbed9ad19..5c0f4bacce 100644 --- a/client/src/app/pages/reports/components/landscape/donut.tsx +++ b/client/src/app/pages/reports/components/landscape/donut.tsx @@ -11,6 +11,7 @@ export interface IDonutProps { total: number; color: string; riskLabel: string; + riskDescription?: string; } export const Donut: React.FC = ({ @@ -18,6 +19,7 @@ export const Donut: React.FC = ({ total, color, riskLabel, + riskDescription, }) => { const { t } = useTranslation(); @@ -42,6 +44,7 @@ export const Donut: React.FC = ({ {riskLabel} + {riskDescription} diff --git a/client/src/app/pages/reports/components/landscape/landscape.tsx b/client/src/app/pages/reports/components/landscape/landscape.tsx index c70ad07dc9..0f3a968036 100644 --- a/client/src/app/pages/reports/components/landscape/landscape.tsx +++ b/client/src/app/pages/reports/components/landscape/landscape.tsx @@ -93,6 +93,7 @@ export const Landscape: React.FC = () => { total={applications.length} color={RISK_LIST["red"].hexColor} riskLabel={t("colors.red")} + // riskDescription={} /> @@ -101,6 +102,7 @@ export const Landscape: React.FC = () => { total={applications.length} color={RISK_LIST["yellow"].hexColor} riskLabel={t("colors.yellow")} + // riskDescription={} /> @@ -109,6 +111,7 @@ export const Landscape: React.FC = () => { total={applications.length} color={RISK_LIST["green"].hexColor} riskLabel={t("colors.green")} + // riskDescription={} /> @@ -117,6 +120,7 @@ export const Landscape: React.FC = () => { total={applications.length} color={RISK_LIST["unknown"].hexColor} riskLabel={`${t("terms.unassessed")}/${t("terms.unknown")}`} + // riskDescription={} /> diff --git a/client/src/app/pages/reports/reports.tsx b/client/src/app/pages/reports/reports.tsx index 02a2b5e6a4..69781efd21 100644 --- a/client/src/app/pages/reports/reports.tsx +++ b/client/src/app/pages/reports/reports.tsx @@ -102,6 +102,13 @@ export const Reports: React.FC = () => { setIsQuestionnaireSelectOpen(false); }; + const questionnaires = assessments.reduce((result: string[], item) => { + if (!result.includes(item.questionnaire.name)) { + result.push(item.questionnaire.name); + } + return result; + }, []); + return ( <> {pageHeaderSection} @@ -137,12 +144,9 @@ export const Reports: React.FC = () => { All questionnaires - {assessments.map((assessment, index) => ( - - {assessment.questionnaire.name} + {questionnaires.map((questionnaire, index) => ( + + {questionnaire} ))}