import type { CandidateSource, CrewStatus } from "@prisma/client";
import type { BadgeProps } from "@/components/ui/badge";

type Variant = NonNullable<BadgeProps["variant"]>;

export const SOURCE_LABEL: Record<CandidateSource, string> = {
  CAREERS: "Careers",
  EX_HAND: "Ex-hand",
  WALK_IN: "Walk-in",
  REFERRAL: "Referral",
  OTHER: "Other",
};

export const SOURCE_OPTIONS: CandidateSource[] = ["CAREERS", "EX_HAND", "WALK_IN", "REFERRAL", "OTHER"];

// Ex-hand is now its own checkbox (not a source) — the Add/Edit form offers only
// the real origins. EX_HAND stays in the enum/label for legacy rows created
// before the split.
export const FORM_SOURCE_OPTIONS: CandidateSource[] = ["CAREERS", "WALK_IN", "REFERRAL", "OTHER"];

export const STATUS_LABEL: Record<CrewStatus, string> = {
  PROSPECT: "Prospect",
  CANDIDATE: "Candidate",
  EMPLOYEE: "Employee",
  EX_HAND: "Ex-hand",
  BLACKLISTED: "Blacklisted",
};

export const STATUS_VARIANT: Record<CrewStatus, Variant> = {
  PROSPECT: "outline",
  CANDIDATE: "default",
  EMPLOYEE: "success",
  EX_HAND: "secondary",
  BLACKLISTED: "danger",
};

// Compact experience label, e.g. "3y 6m", "8m", "—".
export function experienceLabel(months: number): string {
  if (!months) return "—";
  const y = Math.floor(months / 12);
  const m = months % 12;
  return [y ? `${y}y` : "", m ? `${m}m` : ""].filter(Boolean).join(" ") || "0m";
}
