import type { MembershipRoleDTO } from '@/lib/types/generated/MembershipRoleDTO';
type LeagueRole = MembershipRoleDTO['value'];

export class LeagueRoleUtility {
  static isLeagueOwnerRole(role: LeagueRole): boolean {
    return role === 'owner';
  }

  static isLeagueAdminRole(role: LeagueRole): boolean {
    return role === 'admin';
  }

  static isLeagueStewardRole(role: LeagueRole): boolean {
    return role === 'steward';
  }

  static isLeagueMemberRole(role: LeagueRole): boolean {
    return role === 'member';
  }

  /**
   * Returns true for roles that should be treated as having elevated permissions.
   * This keeps UI logic open for future roles like steward, streamer, sponsor.
   */
  static isLeagueAdminOrHigherRole(role: LeagueRole): boolean {
    return role === 'owner' || role === 'admin' || role === 'steward';
  }

  /**
   * Ordering helper for sorting memberships in tables.
   */
  static getLeagueRoleOrder(role: LeagueRole): number {
    const order: Record<LeagueRole, number> = {
      owner: 0,
      admin: 1,
      steward: 2,
      member: 3,
    };
    return order[role] ?? 99;
  }
}