shoc-frontend-new/src/domain/work-orders/utils/severity-escalation.ts
Arthur Bassi 27ddeb2903 feat(work-orders): align inline type correction with the board AAP
Keep type correction on the board: Type & severity, SEV toast, and audit copy.
2026-09-03 16:30:10 -03:00

20 lines
757 B
TypeScript

import {
SEVERITY_LEVELS,
type WorkOrderSeverity,
} from "@/domain/work-orders/types/work-order-severity";
function isCriticalSeverity(severity: WorkOrderSeverity | null | undefined): severity is 1 | 2 {
return severity === 1 || severity === 2;
}
/** AAP: toast only when severity newly enters SEV 1/2 — not on re-save of the same value. */
export function shouldAnnounceSeverityEscalation(
previous: WorkOrderSeverity | null | undefined,
next: WorkOrderSeverity | null | undefined,
): next is 1 | 2 {
return isCriticalSeverity(next) && !isCriticalSeverity(previous);
}
export function formatSeverityEscalationToast(woNumber: string, severity: 1 | 2): string {
return `WO #${woNumber} escalated to ${SEVERITY_LEVELS[severity].label}.`;
}