import type { ProfileLeaguesViewData } from '@/lib/view-data/ProfileLeaguesViewData';

interface ProfileLeaguesPageDto {
  ownedLeagues: Array<{
    leagueId: string;
    name: string;
    description: string;
    membershipRole: 'owner' | 'admin' | 'steward' | 'member';
  }>;
  memberLeagues: Array<{
    leagueId: string;
    name: string;
    description: string;
    membershipRole: 'owner' | 'admin' | 'steward' | 'member';
  }>;
}

/**
 * ViewData Builder for Profile Leagues page
 * Transforms Page DTO to ViewData for templates
 */
export class ProfileLeaguesViewDataBuilder {
  static build(apiDto: ProfileLeaguesPageDto): ProfileLeaguesViewData {
    return {
      ownedLeagues: apiDto.ownedLeagues.map((league: { leagueId: string; name: string; description: string; membershipRole: 'owner' | 'admin' | 'steward' | 'member'; }) => ({
        leagueId: league.leagueId,
        name: league.name,
        description: league.description,
        membershipRole: league.membershipRole,
      })),
      memberLeagues: apiDto.memberLeagues.map((league: { leagueId: string; name: string; description: string; membershipRole: 'owner' | 'admin' | 'steward' | 'member'; }) => ({
        leagueId: league.leagueId,
        name: league.name,
        description: league.description,
        membershipRole: league.membershipRole,
      })),
    };
  }
}
