import type { GetRaceWithSOFResult } from '@core/racing/application/use-cases/GetRaceWithSOFUseCase';
import type { RaceWithSOFDTO } from '../dtos/RaceWithSOFDTO';

export type GetRaceWithSOFResponseModel = RaceWithSOFDTO;

export class RaceWithSOFPresenter {
  private model: GetRaceWithSOFResponseModel | null = null;

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

  present(result: GetRaceWithSOFResult): void {
    this.model = {
      id: result.race.id,
      track: result.race.track,
      strengthOfField: result.strengthOfField,
    } as RaceWithSOFDTO;
  }

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

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

    return this.model;
  }

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