import type { ILeagueStandingsPresenter, LeagueStandingsResultDTO, LeagueStandingsViewModel, StandingItemViewModel, } from '@gridpilot/racing/application/presenters/ILeagueStandingsPresenter'; export class LeagueStandingsPresenter implements ILeagueStandingsPresenter { private viewModel: LeagueStandingsViewModel | null = null; reset(): void { this.viewModel = null; } present(dto: LeagueStandingsResultDTO): void { const standingItems: StandingItemViewModel[] = dto.standings.map((standing) => { const raw = standing as unknown as { seasonId?: string; podiums?: number; }; return { id: standing.id, leagueId: standing.leagueId, seasonId: raw.seasonId ?? '', driverId: standing.driverId, position: standing.position, points: standing.points, wins: standing.wins, podiums: raw.podiums ?? 0, racesCompleted: standing.racesCompleted, }; }); this.viewModel = { leagueId: dto.standings[0]?.leagueId ?? '', standings: standingItems, }; } getViewModel(): LeagueStandingsViewModel | null { return this.viewModel; } }