import type { GetDashboardDataOutput } from '@core/analytics/application/use-cases/GetDashboardDataUseCase';
import type { GetDashboardDataOutputDTO } from '../dtos/GetDashboardDataOutputDTO';

export class GetDashboardDataPresenter {
  private model: GetDashboardDataOutputDTO | null = null;

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

  transform(result: GetDashboardDataOutput): GetDashboardDataOutputDTO {
    this.model = {
      totalUsers: result.totalUsers,
      activeUsers: result.activeUsers,
      totalRaces: result.totalRaces,
      totalLeagues: result.totalLeagues,
    };
    return this.model;
  }

  get responseModel(): GetDashboardDataOutputDTO {
    if (!this.model) throw new Error('Presenter not transformed');
    return this.model;
  }

  getResponseModel(): GetDashboardDataOutputDTO {
    if (!this.model) throw new Error('Presenter not transformed');
    return this.model;
  }
}