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

export class GetDashboardDataPresenter implements UseCaseOutputPort<GetDashboardDataOutput> {
  private model: GetDashboardDataOutputDTO | null = null;

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

  present(result: GetDashboardDataOutput): void {
    this.model = {
      totalUsers: result.totalUsers,
      activeUsers: result.activeUsers,
      totalRaces: result.totalRaces,
      totalLeagues: result.totalLeagues,
    };
  }

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

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