import type { GetLeagueStatsResult } from '@core/racing/application/use-cases/GetLeagueStatsUseCase';
import type { Presenter } from '../../../shared/presentation/Presenter';
import { LeagueStatsDTO } from '../dtos/LeagueStatsDTO';

export class LeagueStatsPresenter implements Presenter<GetLeagueStatsResult, LeagueStatsDTO> {
  private result: LeagueStatsDTO | null = null;

  reset() {
    this.result = null;
  }

  present(dto: GetLeagueStatsResult) {
    this.result = {
      totalMembers: dto.driverCount,
      totalRaces: dto.raceCount,
      averageRating: dto.averageRating,
    };
  }

  getResponseModel(): LeagueStatsDTO | null {
    return this.result;
  }
}