import type {
  ILeagueScoringPresetsPresenter,
  LeagueScoringPresetsViewModel,
  LeagueScoringPresetsResultDTO,
} from '@core/racing/application/presenters/ILeagueScoringPresetsPresenter';

export class LeagueScoringPresetsPresenter implements ILeagueScoringPresetsPresenter {
  private viewModel: LeagueScoringPresetsViewModel | null = null;

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

  present(dto: LeagueScoringPresetsResultDTO): void {
    const { presets } = dto;

    this.viewModel = {
      presets,
      totalCount: presets.length,
    };
  }

  getViewModel(): LeagueScoringPresetsViewModel {
    if (!this.viewModel) {
      throw new Error('Presenter has not been called yet');
    }
    return this.viewModel;
  }
}