import { Check } from "lucide-react"; import { Box, Group, Stack, Text } from "@mantine/core"; import type { Freight } from "@edr/types"; const BRAND_GREEN = "var(--freight-brand, #0A6F4D)"; const IMPORT_PHASES = [ "CUSTOMER_INTAKE", "GL_ET_REVIEW", "GL_ET_OUTPUT", "CUSTOMER_DUTY", "GL_ET_POST_CLEARANCE", "GL_DJ_COLLECTION", ] as const; const PHASE_LABELS: Record = { CUSTOMER_INTAKE: "Customer docs", GL_ET_REVIEW: "GL ET review", GL_DJ_COLLECTION: "GL Djibouti DO", GL_ET_OUTPUT: "Declaration", CUSTOMER_DUTY: "Duty / customer pays", GL_ET_POST_CLEARANCE: "Transit & finalize", GL_DJ_LOADING: "Loading", POST_TRANSIT: "Transit", }; const EXPORT_PHASES = [ "CUSTOMER_INTAKE", "GL_ET_REVIEW", "GL_DJ_COLLECTION", "GL_ET_OUTPUT", "GL_ET_POST_CLEARANCE", ] as const; function phaseIndex(phases: readonly string[], current?: string | null): number { if (!current) return 0; const idx = phases.indexOf(current); return idx >= 0 ? idx : 0; } export function ClearancePhaseStepper({ clearance, tradeDirection, compact = false, }: { clearance?: Freight.ContractClearanceView | Freight.ClearanceView | null; tradeDirection?: string; compact?: boolean; }) { const phases = tradeDirection === "EXPORT" ? EXPORT_PHASES : IMPORT_PHASES; const current = clearance?.phase ?? phases[0]; const activeIdx = phaseIndex(phases, current); return ( {phases.map((phase, index) => { const isComplete = index < activeIdx; const isActive = index === activeIdx; const isLast = index === phases.length - 1; return ( {isComplete ? : null} {PHASE_LABELS[phase] ?? phase} {!isLast && ( )} ); })} ); }