Skip to content

Commit

Permalink
Changes after review
Browse files Browse the repository at this point in the history
Signed-off-by: Maayan Hadasi <[email protected]>
  • Loading branch information
mguetta1 committed Nov 18, 2024
1 parent f6e5257 commit d2096ca
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ 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;
}
Expand Down Expand Up @@ -34,30 +33,32 @@ export const ApplicationAnalysisStatus: React.FC<
> = ({ state }) => {
return <IconedStatus preset={getTaskStatus(state)} />;
};
export const mapAnalysisStateToLabel = (value: TaskState) => {

export const mapAnalysisStateToLabel = (
value: TaskState,
t: (key: string) => string
) => {
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<IconedStatusPreset, { label: string }> => ({
InProgressInheritedReviews: { label: t("terms.inProgress") },
InProgressInheritedAssessments: { label: t("terms.inProgress") },
InheritedReviews: { label: t("terms.completed") },
InheritedAssessments: { label: t("terms.completed") },
Canceled: { label: t("terms.canceled") },
Scheduled: { label: t("terms.scheduled") },
Completed: { label: t("terms.completed") },
CompletedWithErrors: { label: t("terms.completedWithErrors") },
Error: { label: t("terms.error") },
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
Scheduled: { label: t("terms.scheduled") },
Ok: { label: t("terms.ok") }, // Add Ok with a label
Unknown: { label: t("terms.unknown") }, // Add Unknown with a label
});

0 comments on commit d2096ca

Please sign in to comment.