/**
 * Static enums for the "Utilisateurs internes" module.
 *
 * Labels live in i18n (`t.internalUsers.roleLabels` / `permissionLabels` / `statusLabels`);
 * these constants only hold the backend codes, their canonical order, and the
 * badge color classes used across the list and dialogs.
 */

export const INTERNAL_ROLE_CODES = [
  "super_admin",
  "admin",
  "support",
  "commercial",
  "read_only",
] as const;

export type InternalRoleCode = (typeof INTERNAL_ROLE_CODES)[number];

export const INTERNAL_USER_STATUSES = ["active", "invited", "suspended"] as const;

export type InternalUserStatus = (typeof INTERNAL_USER_STATUSES)[number];

/** Status string -> numeric code expected by the Update endpoint (0=Invité, 1=Actif, 2=Suspendu). */
export const INTERNAL_STATUS_TO_CODE: Record<InternalUserStatus, "0" | "1" | "2"> = {
  invited: "0",
  active: "1",
  suspended: "2",
};

/** The 10 permission codes, in the order they appear in the permission editors. */
export const INTERNAL_PERMISSION_CODES = [
  "tickets.manage",
  "tickets.view",
  "companies.manage",
  "users.manage",
  "internal.manage",
  "telematic.manage",
  "catalog.manage",
  "subscriptions.manage",
  "admin_vehicles.manage",
  "logs.view",
] as const;

export const INTERNAL_ROLE_BADGE: Record<string, string> = {
  super_admin: "bg-purple-50 text-purple-700 dark:bg-purple-950/40 dark:text-purple-400",
  admin: "bg-blue-50 text-blue-700 dark:bg-blue-950/40 dark:text-blue-400",
  support: "bg-emerald-50 text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-400",
  commercial: "bg-amber-50 text-amber-700 dark:bg-amber-950/40 dark:text-amber-400",
  read_only: "bg-gray-100 text-gray-600 dark:bg-gray-800/40 dark:text-gray-400",
};

export const INTERNAL_STATUS_BADGE: Record<string, string> = {
  active: "bg-emerald-50 text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-400",
  invited: "bg-amber-50 text-amber-700 dark:bg-amber-950/40 dark:text-amber-400",
  suspended: "bg-red-50 text-red-700 dark:bg-red-950/40 dark:text-red-400",
};
