export const APP_ROLES = [
  "super_admin",
  "admin",
  "rh",
  "responsable",
  "lecture",
] as const;

export type AppRole = (typeof APP_ROLES)[number];

export const ROLE_LABELS: Record<AppRole, string> = {
  super_admin: "Super administrateur",
  admin: "Administrateur",
  rh: "RH",
  responsable: "Responsable",
  lecture: "Lecture seule",
};

export const API_ASSIGNABLE_ROLES = [
  "admin",
  "rh",
  "responsable",
  "lecture",
] as const;

export function normalizeAppRole(value: string | null | undefined): AppRole | null {
  if (value === "user") {
    return "lecture";
  }

  return APP_ROLES.find((role) => role === value) ?? null;
}

