diff --git a/client/src/app/pages/applications/applications-table/applications-table.tsx b/client/src/app/pages/applications/applications-table/applications-table.tsx index 7a443f4184..e6c8ad8788 100644 --- a/client/src/app/pages/applications/applications-table/applications-table.tsx +++ b/client/src/app/pages/applications/applications-table/applications-table.tsx @@ -482,6 +482,22 @@ export const ApplicationsTable: React.FC = () => { return matchString; }, }, + { + key: "risk", + title: t("terms.risk"), + type: FilterType.multiselect, + placeholderText: + t("actions.filterBy", { + what: t("terms.risk").toLowerCase(), + }) + "...", + selectOptions: [ + { key: "green", value: "Green" }, + { key: "yellow", value: "Yellow" }, + { key: "red", value: "Red" }, + { key: "unknown", value: "Unknown" }, + ], + getItemValue: (item) => item.risk || "", + }, ], initialItemsPerPage: 10, hasActionsColumn: true, diff --git a/client/src/app/pages/reports/components/application-landscape/application-landscape.tsx b/client/src/app/pages/reports/components/application-landscape/application-landscape.tsx index 1bd5a16ff7..3c0107c833 100644 --- a/client/src/app/pages/reports/components/application-landscape/application-landscape.tsx +++ b/client/src/app/pages/reports/components/application-landscape/application-landscape.tsx @@ -14,6 +14,9 @@ import { ConditionalRender } from "@app/components/ConditionalRender"; import { useFetchAssessmentsWithArchetypeApplications } from "@app/queries/assessments"; import { useFetchApplications } from "@app/queries/applications"; import { Donut } from "../donut/donut"; +import { serializeFilterUrlParams } from "@app/hooks/table-controls"; +import { Paths } from "@app/Paths"; +import { Link } from "react-router-dom"; interface IAggregateRiskData { green: number; @@ -142,7 +145,9 @@ export const ApplicationLandscape: React.FC = ({ value={landscapeData.red} total={landscapeData.applicationsCount} color={RISK_LIST.red.hexColor} - riskLabel={t("terms.highRisk")} + riskLabel={ + {t("terms.highRisk")} + } riskDescription={questionnaire?.riskMessages?.red ?? ""} /> @@ -153,7 +158,11 @@ export const ApplicationLandscape: React.FC = ({ value={landscapeData.yellow} total={landscapeData.applicationsCount} color={RISK_LIST.yellow.hexColor} - riskLabel={t("terms.mediumRisk")} + riskLabel={ + + {t("terms.mediumRisk")} + + } riskDescription={questionnaire?.riskMessages?.yellow ?? ""} /> @@ -164,7 +173,9 @@ export const ApplicationLandscape: React.FC = ({ value={landscapeData.green} total={landscapeData.applicationsCount} color={RISK_LIST.green.hexColor} - riskLabel={t("terms.lowRisk")} + riskLabel={ + {t("terms.lowRisk")} + } riskDescription={questionnaire?.riskMessages?.green ?? ""} /> @@ -175,8 +186,11 @@ export const ApplicationLandscape: React.FC = ({ value={landscapeData.unassessed} total={landscapeData.applicationsCount} color={RISK_LIST.unknown.hexColor} - riskLabel={`${t("terms.unassessed")}/${t("terms.unknown")}`} - riskDescription={questionnaire?.riskMessages?.unknown ?? ""} + riskLabel={ + + {`${t("terms.unassessed")}/${t("terms.unknown")}`} + + } /> @@ -184,3 +198,16 @@ export const ApplicationLandscape: React.FC = ({ ); }; + +const getRisksUrl = (risks: string[]) => { + const filterValues = { + risk: risks, + }; + + const serializedParams = serializeFilterUrlParams(filterValues); + + const queryString = serializedParams.filters + ? `filters=${serializedParams.filters}` + : ""; + return `${Paths.applications}?${queryString}`; +}; diff --git a/client/src/app/pages/reports/components/donut/donut.tsx b/client/src/app/pages/reports/components/donut/donut.tsx index 4c7912a139..8c1d413266 100644 --- a/client/src/app/pages/reports/components/donut/donut.tsx +++ b/client/src/app/pages/reports/components/donut/donut.tsx @@ -17,8 +17,8 @@ export interface IDonutProps { value: number; total: number; color: string; - riskLabel: string; - riskDescription?: string; + riskLabel: string | React.ReactElement; + riskDescription?: string | React.ReactElement; isAssessment: boolean; } diff --git a/client/src/app/queries/risks.ts b/client/src/app/queries/risks.ts deleted file mode 100644 index cc5b8bc9e3..0000000000 --- a/client/src/app/queries/risks.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { useQuery } from "@tanstack/react-query"; -import { AssessmentRisk } from "@app/api/models"; - -export const RisksQueryKey = "risks"; - -/** @deprecated Risk is attached to assessments now. */ -export const useFetchRisks = (applicationIDs: number[]) => { - const { data, refetch, isFetching, error } = useQuery({ - queryKey: ["assessmentrisks", applicationIDs], - queryFn: async () => { - if (applicationIDs.length > 0) - // return (await getAssessmentLandscape(applicationIDs)).data; - //TODO see if we still need this - return []; - else return []; - }, - onError: (error) => console.log("error, ", error), - }); - - return { - risks: data || [], - isFetching, - error, - refetch, - }; -};