import { LeagueStandingDTO } from '../types/generated/LeagueStandingDTO'; import { StandingEntryViewModel } from './StandingEntryViewModel'; export class LeagueStandingsViewModel { standings: StandingEntryViewModel[]; constructor(dto: { standings: LeagueStandingDTO[] }, currentUserId: string, previousStandings?: LeagueStandingDTO[]) { const leaderPoints = dto.standings[0]?.points || 0; this.standings = dto.standings.map((entry, index) => { const nextPoints = dto.standings[index + 1]?.points || entry.points; const previousPosition = previousStandings?.find(p => p.driverId === entry.driverId)?.position; return new StandingEntryViewModel(entry, leaderPoints, nextPoints, currentUserId, previousPosition); }); } // Note: The generated DTO doesn't have these fields // These will need to be added when the OpenAPI spec is updated drivers: any[] = []; memberships: any[] = []; }