import type { InternalUserStatus } from "@/shared/constants/internal-users";

export interface InternalUser {
  id: number;
  first_name: string;
  last_name: string;
  full_name: string;
  email: string;
  role: string;
  role_label: string;
  status: InternalUserStatus;
  last_activity: string | null;
  last_active_at: string | null;
  created_at: string;
  profile_picture: string | null;
}

export interface InternalUserStats {
  total: number;
  active: number;
  invited: number;
  suspended: number;
}

export interface InviteInternalUserPayload {
  full_name: string;
  email: string;
  role: string;
  phone?: string;
}

export interface UpdateInternalUserPayload {
  full_name?: string;
  email?: string;
  role?: string;
  /** Numeric status code: 0=Invité, 1=Actif, 2=Suspendu. */
  status?: string;
}

/** A single row of the per-user permission matrix (effective = the toggle state). */
export interface PermissionMatrixItem {
  id: number;
  code: string;
  resource: string;
  action: string;
  from_role: boolean;
  override: boolean | null;
  effective: boolean;
}

export interface PermissionMatrix {
  role: { id: number; code: string; name: string };
  permissions: PermissionMatrixItem[];
}
