import type { GetTeamsLeaderboardOutputDTO } from '@/lib/types/generated/GetTeamsLeaderboardOutputDTO';
import type { TeamRankingsViewData } from '@/lib/view-data/TeamRankingsViewData';

export class TeamRankingsViewDataBuilder {
  static build(apiDto: GetTeamsLeaderboardOutputDTO): TeamRankingsViewData {
    const allTeams = apiDto.teams.map((team, index) => ({
      id: team.id,
      name: team.name,
      tag: team.tag,
      memberCount: team.memberCount,
      category: undefined,
      totalWins: team.totalWins || 0,
      logoUrl: team.logoUrl || '',
      position: index + 1,
      isRecruiting: team.isRecruiting,
      performanceLevel: team.performanceLevel || 'N/A',
      rating: team.rating || 0,
      totalRaces: team.totalRaces || 0,
    }));

    return {
      teams: allTeams,
      podium: allTeams.slice(0, 3),
      recruitingCount: apiDto.recruitingCount,
    };
  }
}
