import type { EmploymentStatus } from "./supabase/types"; // Langzeitabwesenheit. // // The database still stores the employment status as 'Karenz' — renaming an // enum value would mean rewriting every stored function that spells it, for // a label change (see supabase/migrations/*_absence_type.sql). So the value // is mapped to its display name here, in the one place the UI reads it from. export const ABSENCE_TYPES = [ "Wochenhilfe (Mutterschutz)", "Elternkarenz (inkl. Väterkarenz)", "Papamonat", "Bildungskarenz", "Bildungsteilzeit", "Präsenzdienst", "Zivildienst", "Langer Krankenstand", "Wiedereingliederungsteilzeit", "Pflegekarenz", "Pflegeteilzeit", "Familienhospizkarenz", "Sabbatical", ] as const; export type AbsenceType = (typeof ABSENCE_TYPES)[number]; export function isAbsenceType(value: string | null | undefined): value is AbsenceType { return ABSENCE_TYPES.includes(value as AbsenceType); } /** Display names for the stored status values. */ const STATUS_LABELS: Record = { Aktiv: "Aktiv", Karenz: "Langzeitabwesenheit", Geplant: "Geplant", Ausgetreten: "Ausgetreten", }; export function statusLabel(status: EmploymentStatus): string { return STATUS_LABELS[status] ?? status; } /** * The chip and the detail header show the specific kind when it is known — * "Bildungskarenz" says more than "Langzeitabwesenheit". Absences recorded * before the type existed have none, and fall back to the generic name * rather than to a guess. */ export function absenceLabel(status: EmploymentStatus, absenceType: string | null | undefined): string { if (status !== "Karenz") return statusLabel(status); return isAbsenceType(absenceType) ? absenceType : STATUS_LABELS.Karenz; }