import { Badge } from "@mantine/core";

const STATUS_COLORS: Record<string, string> = {
  DRAFT: "gray",
  SCHEDULED: "blue",
  DISPATCHED: "edr-green",
  ARRIVED: "teal",
  CANCELLED: "red",
};

export function ScheduleStatusBadge({ status }: { status: string }) {
  return (
    <Badge variant="light" color={STATUS_COLORS[status] ?? "gray"} size="sm">
      {status}
    </Badge>
  );
}

export function FreightTypeBadge({ freightType }: { freightType?: string | null }) {
  if (!freightType) return <Badge variant="light" color="gray" size="sm">—</Badge>;
  const color =
    freightType === "BULK" ? "orange" : freightType === "MIXED" ? "grape" : "cyan";
  return (
    <Badge variant="light" color={color} size="sm">
      {freightType}
    </Badge>
  );
}

export function SchedulingStatusBadge({ status }: { status?: string | null }) {
  if (!status) return null;
  const colors: Record<string, string> = {
    NOT_SCHEDULED: "gray",
    HOLDING: "yellow",
    ELIGIBLE: "blue",
    SCHEDULED: "indigo",
    DISPATCHED: "edr-green",
    WAITING_FOR_WAGON: "yellow",
    MANUAL_ONLY: "orange",
  };
  return (
    <Badge variant="light" color={colors[status] ?? "gray"} size="sm">
      {status.replace(/_/g, " ")}
    </Badge>
  );
}
