import type { RepairPriority, RepairStatus } from "@/types/repair";

const statusLabels: Record<RepairStatus, string> = {
  new: "Neu",
  accepted: "Angenommen",
  diagnosis: "Diagnose",
  estimate: "Kostenvoranschlag",
  waiting_for_customer: "Wartet auf Kunde",
  approved: "Freigegeben",
  repair: "Reparatur",
  final_test: "Endprüfung",
  ready_for_pickup: "Abholbereit",
  shipped: "Versand",
  completed: "Abgeschlossen",
  cancelled: "Storniert",
};

const priorityLabels: Record<RepairPriority, string> = {
  low: "Niedrig",
  normal: "Normal",
  high: "Hoch",
  urgent: "Dringend",
};

const statusColors: Record<RepairStatus, string> = {
  new: "bg-blue-50 text-blue-700 ring-blue-600/20",
  accepted: "bg-sky-50 text-sky-700 ring-sky-600/20",
  diagnosis: "bg-violet-50 text-violet-700 ring-violet-600/20",
  estimate: "bg-amber-50 text-amber-700 ring-amber-600/20",
  waiting_for_customer: "bg-orange-50 text-orange-700 ring-orange-600/20",
  approved: "bg-emerald-50 text-emerald-700 ring-emerald-600/20",
  repair: "bg-cyan-50 text-cyan-700 ring-cyan-600/20",
  final_test: "bg-indigo-50 text-indigo-700 ring-indigo-600/20",
  ready_for_pickup: "bg-lime-50 text-lime-700 ring-lime-600/20",
  shipped: "bg-teal-50 text-teal-700 ring-teal-600/20",
  completed: "bg-slate-100 text-slate-700 ring-slate-500/20",
  cancelled: "bg-red-50 text-red-700 ring-red-600/20",
};

const priorityColors: Record<RepairPriority, string> = {
  low: "bg-slate-100 text-slate-700 ring-slate-500/20",
  normal: "bg-blue-50 text-blue-700 ring-blue-600/20",
  high: "bg-amber-50 text-amber-700 ring-amber-600/20",
  urgent: "bg-red-50 text-red-700 ring-red-600/20",
};

function Badge({ label, color }: { label: string; color: string }) {
  return <span className={`inline-flex rounded-full px-2 py-1 text-xs font-medium ring-1 ${color}`}>{label}</span>;
}

export function RepairStatusBadge({ status }: { status: RepairStatus }) {
  return <Badge label={statusLabels[status]} color={statusColors[status]} />;
}

export function RepairPriorityBadge({ priority }: { priority: RepairPriority }) {
  return <Badge label={priorityLabels[priority]} color={priorityColors[priority]} />;
}

export { priorityLabels, statusLabels };
