export enum Role {
  USER = 'USER',
  ADMIN = 'ADMIN',
  SUPER_ADMIN = 'SUPER_ADMIN',
}

export const ROLE_HIERARCHY: Record<Role, Role[]> = {
  [Role.USER]: [Role.USER],
  [Role.ADMIN]: [Role.USER, Role.ADMIN],
  [Role.SUPER_ADMIN]: [Role.USER, Role.ADMIN, Role.SUPER_ADMIN],
};

export function hasRole(userRole: string | undefined, required: Role): boolean {
  if (!userRole) return false;
  const resolved = ROLE_HIERARCHY[userRole as Role];
  if (!resolved) return false;
  return resolved.includes(required);
}
