// Single frontend source of truth for the canonical job pipeline. // Mirrors the backend JobPipeline (JobTrackerApi/Services/JobPipeline.cs); keep the two in sync. export const PIPELINE_STATUSES = ["Applied", "Waiting", "Interview", "Offer", "Rejected", "Ghosted"] as const; export type PipelineStatus = (typeof PIPELINE_STATUSES)[number]; export type StatusTone = "primary" | "info" | "success" | "warning" | "error" | "default"; // Legacy/synonym spellings collapse onto a canonical stage (matches the backend alias map). const ALIASES: Record = { interviewing: "Interview", interviews: "Interview", interviewed: "Interview", declined: "Rejected", "no response": "Ghosted", "no reply": "Ghosted", pending: "Waiting", "awaiting response": "Waiting", }; /** Canonical status for a raw value, or "Other" for unknown/custom statuses. */ export function normalizeStatus(status?: string | null): PipelineStatus | "Other" { const trimmed = (status ?? "").trim(); if (!trimmed) return "Applied"; const exact = PIPELINE_STATUSES.find((s) => s.toLowerCase() === trimmed.toLowerCase()); if (exact) return exact; const alias = ALIASES[trimmed.toLowerCase()]; return alias ?? "Other"; } /** MUI palette key for a status; both chip color and board accent derive from this. */ export function statusTone(status?: string | null): StatusTone { switch (normalizeStatus(status)) { case "Offer": return "success"; case "Rejected": return "error"; case "Waiting": case "Ghosted": return "warning"; case "Interview": return "info"; case "Applied": return "primary"; default: return "default"; } } const LABEL_KEYS: Record = { Applied: "statusApplied", Waiting: "statusWaiting", Interview: "statusInterview", Offer: "statusOffer", Rejected: "statusRejected", Ghosted: "statusGhosted", }; /** Localized label for a status, falling back to the raw value for custom statuses. */ export function statusLabel(t: (key: any, params?: any) => string, status: string): string { const normalized = normalizeStatus(status); return normalized === "Other" ? status : t(LABEL_KEYS[normalized]); }