import { LeagueSummaryViewModel } from '@/lib/view-models/LeagueSummaryViewModel';
import { LeaguesViewData } from '@/lib/view-data/LeaguesViewData';

export class LeagueSummaryViewModelBuilder {
  static build(league: LeaguesViewData['leagues'][number]): LeagueSummaryViewModel {
    return {
      id: league.id,
      name: league.name,
      description: league.description ?? '',
      logoUrl: league.logoUrl,
      ownerId: league.ownerId,
      createdAt: league.createdAt,
      maxDrivers: league.maxDrivers,
      usedDriverSlots: league.usedDriverSlots,
      maxTeams: league.maxTeams ?? 0,
      usedTeamSlots: league.usedTeamSlots ?? 0,
      structureSummary: league.structureSummary,
      timingSummary: league.timingSummary,
      category: league.category ?? undefined,
      scoring: league.scoring ? {
        ...league.scoring,
        primaryChampionshipType: league.scoring.primaryChampionshipType as 'driver' | 'team' | 'nations' | 'trophy',
      } : undefined,
    };
  }
}
