import type {
  IRaceRegistrationsPresenter,
  RaceRegistrationsViewModel,
  RaceRegistrationsResultDTO,
} from '@core/racing/application/presenters/IRaceRegistrationsPresenter';

export class RaceRegistrationsPresenter implements IRaceRegistrationsPresenter {
  private viewModel: RaceRegistrationsViewModel | null = null;

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

  present(input: RaceRegistrationsResultDTO): void {
    const { registeredDriverIds } = input;
    this.viewModel = {
      registeredDriverIds,
      count: registeredDriverIds.length,
    };
  }

  getViewModel(): RaceRegistrationsViewModel | null {
    return this.viewModel;
  }
}