"use client";

import { Badge } from "@/src/shared/ui";
import { cn } from "@/lib/utils";
import { appointmentStatusTone, prescriptionStatusTone } from "./tokens";

const statusLabels: Record<string, string> = {
  draft: "پیش‌نویس",
  confirmed: "تأیید شده",
  checked_in: "پذیرش",
  completed: "انجام شد",
  cancelled: "لغو",
  no_show: "عدم حضور",
  submitted: "ارسال شده",
  accepted: "پذیرفته",
  preparing: "در حال آماده‌سازی",
  ready: "آماده",
  picked_up: "تحویل شد",
  active: "فعال",
  pending: "در انتظار",
  in_progress: "در حال انجام",
  deferred: "موکول",
  finalized: "نهایی",
  queued: "در صف",
};

type Domain = "appointment" | "prescription" | "visit" | "generic";

export function MedicalStatusChip({
  status,
  domain = "generic",
  className,
}: {
  status: string;
  domain?: Domain;
  className?: string;
}) {
  const tone =
    domain === "appointment"
      ? appointmentStatusTone[status] ?? "default"
      : domain === "prescription"
        ? prescriptionStatusTone[status] ?? "default"
        : "default";

  return (
    <Badge tone={tone} className={cn("font-medium", className)}>
      {statusLabels[status] ?? status}
    </Badge>
  );
}
