import { BookingStatus } from "../types/type"; interface StatusToken { label: string; /** Dot + text color. */ color: string; /** Tinted pill background. */ bg: string; } export const BOOKING_STATUS_TOKENS: Record = { pending: { label: "Pending", color: "#c98a1a", bg: "#fdf3e2" }, confirmed: { label: "Confirmed", color: "#0f8f8f", bg: "#e4f6f6" }, rescheduled: { label: "Rescheduled", color: "#0f8f8f", bg: "#e4f6f6" }, "in-progress": { label: "In-Progress", color: "#8b5cf6", bg: "#efeafb" }, completed: { label: "Completed", color: "#2fbf6f", bg: "#e6f8ee" }, cancelled: { label: "Cancelled", color: "#c0392b", bg: "#fdecea" }, }; const FALLBACK: StatusToken = { label: "Pending", color: "#c98a1a", bg: "#fdf3e2" }; /** * The API sends PascalCase statuses ("InProgress", "Confirmed"); the design * tokens are keyed lower-kebab. Normalize so either form resolves. */ export const normalizeStatus = (status?: string): BookingStatus | undefined => { if (!status) return undefined; const key = status.trim().toLowerCase().replace(/[\s_]+/g, "-"); switch (key) { case "inprogress": case "in-progress": return "in-progress"; case "pending": case "confirmed": case "rescheduled": case "completed": case "cancelled": return key; case "canceled": return "cancelled"; default: return undefined; } }; export const getStatusToken = (status?: string): StatusToken => { const key = normalizeStatus(status); return (key && BOOKING_STATUS_TOKENS[key]) || FALLBACK; };