import { LOAD_STATUS_LABELS, type LoadStatus } from "@/src/modules/loads/load-status";

const styles: Record<LoadStatus, string> = {
  DRAFT: "bg-gray-100 text-gray-700",
  AVAILABLE: "bg-blue-100 text-blue-700",
  ASSIGNED: "bg-indigo-100 text-indigo-700",
  IN_TRANSIT: "bg-amber-100 text-amber-800",
  DELIVERED: "bg-emerald-100 text-emerald-700",
  INVOICED: "bg-purple-100 text-purple-700",
  PAID_FULL: "bg-green-100 text-green-700",
  CANCELLED: "bg-red-100 text-red-700",
};

export function LoadStatusBadge({ status }: { status: string }) {
  const safeStatus = (status in styles ? status : "DRAFT") as LoadStatus;

  return (
    <span className={`inline-flex rounded-full px-2.5 py-1 text-xs font-semibold ${styles[safeStatus]}`}>
      {LOAD_STATUS_LABELS[safeStatus]}
    </span>
  );
}
