import { IGetLeagueSchedulePresenter, GetLeagueScheduleResultDTO, LeagueScheduleViewModel } from '@core/racing/application/presenters/IGetLeagueSchedulePresenter';

export class LeagueSchedulePresenter implements IGetLeagueSchedulePresenter {
  private result: LeagueScheduleViewModel | null = null;

  reset() {
    this.result = null;
  }

  present(dto: GetLeagueScheduleResultDTO) {
    this.result = {
      races: dto.races.map(race => ({
        id: race.id,
        name: race.name,
        date: race.scheduledAt.toISOString(),
      })),
    };
  }

  getViewModel(): LeagueScheduleViewModel | null {
    return this.result;
  }
}