import { t } from "../../lib/i18n";

export const userStatusValues = [
  "active",
  "temporary_leave",
  "suspended",
  "preboarding",
  "baron_guest",
  "extended_leave",
  "archived",
] as const;

export type UserStatusValue = (typeof userStatusValues)[number];

export function normalizeUserStatusValue(
  status?: string | null,
): UserStatusValue {
  switch ((status ?? "").trim().toLowerCase()) {
    case "active":
      return "active";
    case "temporary_leave":
    case "leave_of_absence":
      return "temporary_leave";
    case "suspended":
    case "blocked":
      return "suspended";
    case "preboarding":
    case "inactive":
      return "preboarding";
    case "baron_guest":
    case "baron_only":
      return "baron_guest";
    case "extended_leave":
      return "extended_leave";
    case "archived":
      return "archived";
    default:
      return "preboarding";
  }
}

export function userStatusLabel(status: string) {
  const normalized = normalizeUserStatusValue(status);
  return t(`ui.common.status.${normalized}`, normalized);
}
