Skip to content

Commit

Permalink
Reduce assessment list to unique questionnaires
Browse files Browse the repository at this point in the history
Signed-off-by: Gilles Dubreuil <[email protected]>
  • Loading branch information
gildub committed Sep 19, 2023
1 parent 856f452 commit 4bd5a21
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
5 changes: 0 additions & 5 deletions client/src/app/api/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions client/src/app/pages/reports/components/landscape/donut.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ export interface IDonutProps {
total: number;
color: string;
riskLabel: string;
riskDescription?: string;
}

export const Donut: React.FC<IDonutProps> = ({
value,
total,
color,
riskLabel,
riskDescription,
}) => {
const { t } = useTranslation();

Expand All @@ -42,6 +44,7 @@ export const Donut: React.FC<IDonutProps> = ({
<StackItem>
<TextContent className="pf-v5-u-text-align-center">
<Text component="h3">{riskLabel}</Text>
<Text component="small">{riskDescription}</Text>
</TextContent>
</StackItem>
</Stack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export const Landscape: React.FC = () => {
total={applications.length}
color={RISK_LIST["red"].hexColor}
riskLabel={t("colors.red")}
// riskDescription={}
/>
</SplitItem>
<SplitItem>
Expand All @@ -101,6 +102,7 @@ export const Landscape: React.FC = () => {
total={applications.length}
color={RISK_LIST["yellow"].hexColor}
riskLabel={t("colors.yellow")}
// riskDescription={}
/>
</SplitItem>
<SplitItem>
Expand All @@ -109,6 +111,7 @@ export const Landscape: React.FC = () => {
total={applications.length}
color={RISK_LIST["green"].hexColor}
riskLabel={t("colors.green")}
// riskDescription={}
/>
</SplitItem>
<SplitItem>
Expand All @@ -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={}
/>
</SplitItem>
</Split>
Expand Down
16 changes: 10 additions & 6 deletions client/src/app/pages/reports/reports.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -137,12 +144,9 @@ export const Reports: React.FC = () => {
<SelectOption key={0} value="All questionnaires">
All questionnaires
</SelectOption>
{assessments.map((assessment, index) => (
<SelectOption
key={index}
value={assessment.questionnaire.name}
>
{assessment.questionnaire.name}
{questionnaires.map((questionnaire, index) => (
<SelectOption key={index} value={questionnaire}>
{questionnaire}
</SelectOption>
))}
</Select>
Expand Down

0 comments on commit 4bd5a21

Please sign in to comment.