import type { GetAllRacesPageDataResult } from '@core/racing/application/use-cases/GetAllRacesPageDataUseCase';
import type { AllRacesPageDTO } from '../dtos/AllRacesPageDTO';

export type AllRacesPageDataResponseModel = AllRacesPageDTO;

export class AllRacesPageDataPresenter {
  private model: AllRacesPageDataResponseModel | null = null;

  reset(): void {
    this.model = null;
  }

  present(result: GetAllRacesPageDataResult): void {
    this.model = {
      races: result.races,
      filters: result.filters,
    };
  }

  getResponseModel(): AllRacesPageDataResponseModel | null {
    return this.model;
  }

  get responseModel(): AllRacesPageDataResponseModel {
    if (!this.model) {
      throw new Error('Presenter not presented');
    }

    return this.model;
  }

  get viewModel(): AllRacesPageDataResponseModel {
    return this.responseModel;
  }
}