/** * Impact Level Scale Configuration * * Different contexts (Risk vs Process vs Asset) use different terminology: * - Risk: Negligible → Critical * - Process: Insignificant → Vital * - Asset: Insignificant → Business Critical */ import type { MessageDescriptor } from "react-intl"; import { messages } from "./messages"; /** Impact level 0-5 as per schema */ export type ImpactLevel = 0 | 1 | 2 | 3 | 4 | 5; export interface ImpactLevelConfig { /** i18n message descriptor for the label */ message: MessageDescriptor; /** Fallback label (used when no IntlProvider) */ fallbackLabel: string; color: string; bgColor: string; barColor: string; } export type ImpactScaleConfig = Record; /** * Risk Scale (default) - Used for Risk assessments * Not rated → Negligible → Low → Medium → High → Critical */ export const riskScale: ImpactScaleConfig = { 0: { message: messages.risk_0, fallbackLabel: "Not rated", color: "text-muted-foreground", bgColor: "bg-muted", barColor: "bg-muted", }, 1: { message: messages.risk_1, fallbackLabel: "Negligible", color: "text-green-700", bgColor: "bg-green-100", barColor: "bg-green-500", }, 2: { message: messages.risk_2, fallbackLabel: "Low", color: "text-lime-700", bgColor: "bg-lime-100", barColor: "bg-lime-500", }, 3: { message: messages.risk_3, fallbackLabel: "Medium", color: "text-yellow-700", bgColor: "bg-yellow-100", barColor: "bg-yellow-500", }, 4: { message: messages.risk_4, fallbackLabel: "High", color: "text-orange-700", bgColor: "bg-orange-100", barColor: "bg-orange-500", }, 5: { message: messages.risk_5, fallbackLabel: "Critical", color: "text-red-700", bgColor: "bg-red-100", barColor: "bg-red-500", }, }; /** * Process Scale - Used for Business Process classifications * Not rated → Insignificant → Low → Relevant → Important → Vital */ export const processScale: ImpactScaleConfig = { 0: { message: messages.process_0, fallbackLabel: "Not rated", color: "text-muted-foreground", bgColor: "bg-muted", barColor: "bg-muted", }, 1: { message: messages.process_1, fallbackLabel: "Insignificant", color: "text-green-700", bgColor: "bg-green-100", barColor: "bg-green-500", }, 2: { message: messages.process_2, fallbackLabel: "Low", color: "text-lime-700", bgColor: "bg-lime-100", barColor: "bg-lime-500", }, 3: { message: messages.process_3, fallbackLabel: "Relevant", color: "text-yellow-700", bgColor: "bg-yellow-100", barColor: "bg-yellow-500", }, 4: { message: messages.process_4, fallbackLabel: "Important", color: "text-orange-700", bgColor: "bg-orange-100", barColor: "bg-orange-500", }, 5: { message: messages.process_5, fallbackLabel: "Vital", color: "text-red-700", bgColor: "bg-red-100", barColor: "bg-red-500", }, }; /** * Asset Scale - Used for Asset criticality * Not classified → Insignificant → Low → Medium → High → Business Critical */ export const assetScale: ImpactScaleConfig = { 0: { message: messages.asset_0, fallbackLabel: "Not classified", color: "text-muted-foreground", bgColor: "bg-muted", barColor: "bg-muted", }, 1: { message: messages.asset_1, fallbackLabel: "Insignificant", color: "text-green-700", bgColor: "bg-green-100", barColor: "bg-green-500", }, 2: { message: messages.asset_2, fallbackLabel: "Low", color: "text-lime-700", bgColor: "bg-lime-100", barColor: "bg-lime-500", }, 3: { message: messages.asset_3, fallbackLabel: "Medium", color: "text-yellow-700", bgColor: "bg-yellow-100", barColor: "bg-yellow-500", }, 4: { message: messages.asset_4, fallbackLabel: "High", color: "text-orange-700", bgColor: "bg-orange-100", barColor: "bg-orange-500", }, 5: { message: messages.asset_5, fallbackLabel: "Business Critical", color: "text-red-700", bgColor: "bg-red-100", barColor: "bg-red-500", }, }; /** Available impact levels for iteration */ export const impactLevels: ImpactLevel[] = [0, 1, 2, 3, 4, 5]; /** Preset scale types */ export type ImpactScalePreset = "risk" | "process" | "asset"; /** Get scale by preset name */ export function getScale(preset: ImpactScalePreset): ImpactScaleConfig { switch (preset) { case "process": return processScale; case "asset": return assetScale; default: return riskScale; } }