/**
 * Maps backend EmployeeRole names to i18n keys under the "roles" namespace.
 * Backend enum: Owner, Manager, Cashier, Waiter, Chef, Delivery.
 */
export type EmployeeRoleName =
  | "Owner"
  | "Manager"
  | "Cashier"
  | "Waiter"
  | "Chef"
  | "Delivery";

export const ROLE_KEYS: Record<string, string> = {
  Owner: "owner",
  Manager: "manager",
  Cashier: "cashier",
  Waiter: "waiter",
  Chef: "chef",
  Delivery: "delivery",
};

export function roleKey(role: string | undefined | null): string {
  if (!role) return "unknown";
  return ROLE_KEYS[role] ?? "unknown";
}

/** Tailwind classes for a colored role badge. */
export function roleBadgeClass(role: string | undefined | null): string {
  switch (role) {
    case "Owner":
      return "bg-primary/10 text-primary border-primary/30";
    case "Manager":
      return "bg-violet-50 text-violet-700 border-violet-200";
    case "Cashier":
      return "bg-blue-50 text-blue-700 border-blue-200";
    case "Chef":
      return "bg-amber-50 text-amber-700 border-amber-200";
    case "Waiter":
      return "bg-emerald-50 text-emerald-700 border-emerald-200";
    case "Delivery":
      return "bg-orange-50 text-orange-700 border-orange-200";
    default:
      return "bg-muted text-muted-foreground border-border";
  }
}
