import type { GetTotalRacesResult } from '@core/racing/application/use-cases/GetTotalRacesUseCase';
import type { RaceStatsDTO } from '../dtos/RaceStatsDTO';

export type GetTotalRacesResponseModel = RaceStatsDTO;

export class GetTotalRacesPresenter {
  private model: GetTotalRacesResponseModel | null = null;

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

  present(result: GetTotalRacesResult): void {
    this.model = {
      totalRaces: result.totalRaces,
    };
  }

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

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

    return this.model;
  }

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