shoc-frontend-new/src/domain/work-orders/utils/reschedule-indicator.ts

17 lines
672 B
TypeScript
Raw Normal View History

import { fmtDate } from "@/domain/work-orders/utils/wizard-date-utils";
export function formatRescheduleCountLabel(count: number): string {
return count === 1 ? "1 time" : `${count} times`;
}
/** Hover copy for the Reschedule pill (count ≥ 2). Uses originalDate when the API sends it. */
export function formatRescheduleHover(count: number, originalDate?: string): string {
const times = formatRescheduleCountLabel(count);
const base = `Rescheduled ${times} — this WO has had its date changed ${times}.`;
const formatted = originalDate ? fmtDate(originalDate) : "";
if (!formatted) {
return base;
}
return `${base} Original date: ${formatted}.`;
}