import { IGetLeagueSeasonsPresenter, GetLeagueSeasonsResultDTO, GetLeagueSeasonsViewModel } from '@core/racing/application/presenters/IGetLeagueSeasonsPresenter';

export class GetLeagueSeasonsPresenter implements IGetLeagueSeasonsPresenter {
  private result: GetLeagueSeasonsViewModel | null = null;

  reset() {
    this.result = null;
  }

  present(dto: GetLeagueSeasonsResultDTO) {
    const seasons = dto.seasons.map(season => ({
      seasonId: season.id,
      name: season.name,
      status: season.status,
      startDate: season.startDate,
      endDate: season.endDate,
      isPrimary: season.isPrimary,
      isParallelActive: season.isParallelActive,
    }));
    this.result = { seasons };
  }

  getViewModel(): GetLeagueSeasonsViewModel {
    if (!this.result) throw new Error('Presenter not presented');
    return this.result;
  }
}