import { Badge } from "@mantine/core";
import { BOOKING_STATUS_STYLES } from "@/features/bookings/booking-status.config";

const statusColorMap: Record<string, string> = {
  DRAFT: "gray",
  SUBMITTED: "yellow",
  CHANGES_REQUESTED: "orange",
  PENDING_APPROVAL: "yellow",
  APPROVED_PENDING_SIGNATURE: "cyan",
  APPROVED: "green",
  CONTRACT_READY: "indigo",
  SIGNED_CUSTOMER: "cyan",
  FULLY_EXECUTED: "indigo",
  PNR_GENERATED: "violet",
  PAYMENT_VERIFICATION_IN_PROGRESS: "yellow",
  PAID: "green",
  IN_TRANSIT: "cyan",
  COMPLETED: "indigo",
  REJECTED: "red",
  CANCELLED: "red",
  PENDING_CONSOLIDATION: "yellow",
  CONSOLIDATED: "indigo",
};

export function BookingStatusBadge({ status }: { status: string }) {
  const style = BOOKING_STATUS_STYLES[status] ?? {
    label: status,
    color: "gray",
  };
  const color = statusColorMap[status] ?? "gray";

  return (
    <Badge
      color={color}
      variant="light"
      size="sm"
      radius="md"
      tt="uppercase"
      fw={600}
      title={style.label}
      style={{
        fontSize: "0.7rem",
        letterSpacing: "0.05em",
        display: "inline-flex",
        maxWidth: "100%",
        whiteSpace: "nowrap",
      }}
    >
      {style.label}
    </Badge>
  );
}
