diff --git a/client/src/app/pages/applications/components/application-analysis-status.tsx b/client/src/app/pages/applications/components/application-analysis-status.tsx index 4462aacaff..18ba6e3e57 100644 --- a/client/src/app/pages/applications/components/application-analysis-status.tsx +++ b/client/src/app/pages/applications/components/application-analysis-status.tsx @@ -2,7 +2,7 @@ import React from "react"; import { TaskState } from "@app/api/models"; import { IconedStatus, IconedStatusPreset } from "@app/components/Icons"; - +import { useTranslation } from "react-i18next"; export interface ApplicationAnalysisStatusProps { state: TaskState; } @@ -34,3 +34,30 @@ export const ApplicationAnalysisStatus: React.FC< > = ({ state }) => { return ; }; +export const mapAnalysisStateToLabel = (value: TaskState) => { + const presetKey: IconedStatusPreset = getTaskStatus(value); + const { t } = useTranslation(); + const presets = buildPresets(t); + const label = presets[presetKey]?.label ?? t("terms.unknown"); + return label; +}; +export const buildPresets = ( + t: (key: string) => string +): Record => ({ + Canceled: { label: t("terms.canceled") }, + Scheduled: { label: t("terms.scheduled") }, + Completed: { label: t("terms.completed") }, + CompletedWithErrors: { label: t("terms.completedWithErrors") }, + Failed: { label: t("terms.failed") }, + InProgress: { label: t("terms.inProgress") }, + NotStarted: { label: t("terms.notStarted") }, + InheritedReviews: { label: t("terms.inheritedReviews") }, + InProgressInheritedReviews: { label: t("terms.inProgressInheritedReviews") }, + InProgressInheritedAssessments: { + label: t("terms.inProgressInheritedAssessments"), + }, + InheritedAssessments: { label: t("terms.inheritedAssessments") }, + Error: { label: t("terms.error") }, // Add Error with a label + Ok: { label: t("terms.ok") }, // Add Ok with a label + Unknown: { label: t("terms.unknown") }, // Add Unknown with a label +});