import type { LucideIcon } from "lucide-react"
import { ShieldCheck, User, UserRound, UserX, Users } from "lucide-react"
import type { AdminUser, AdminUserRole, AdminUserStatus } from "@/lib/api/admin-types"

export const USER_ROLE_LABELS: Record<AdminUserRole, string> = {
  admin: "Administrateur",
  user: "Utilisateur",
  guest: "Invité",
  suspended: "Suspendu",
}

export const USER_ROLE_ICONS: Record<AdminUserRole, LucideIcon> = {
  admin: ShieldCheck,
  user: User,
  guest: UserRound,
  suspended: UserX,
}

export const USER_ROLE_FILTER_ALL_ICON = Users

export function resolveUserRole(user: {
  role?: AdminUserRole
  status?: AdminUserStatus
  platform_admin?: boolean
}): AdminUserRole {
  if (user.role) return user.role
  if (user.status === "disabled") return "suspended"
  if (user.status === "invited") return "guest"
  if (user.platform_admin) return "admin"
  return "user"
}

export const USER_ROLE_DESCRIPTIONS: Record<AdminUserRole, string> = {
  admin: "Accès complet à l'administration et à toutes les applications.",
  user: "Accès standard à la suite (mail, drive, contacts, etc.).",
  guest: "Accès limité au drive : fichiers partagés et contenus envoyés uniquement.",
  suspended: "Compte bloqué, aucun accès aux services.",
}
