import type { GetSponsorshipPricingResult } from '@core/racing/application/use-cases/GetSponsorshipPricingUseCase';
import { GetEntitySponsorshipPricingResultDTO } from '../dtos/GetEntitySponsorshipPricingResultDTO';

export class GetSponsorshipPricingPresenter {
  private result: GetEntitySponsorshipPricingResultDTO | null = null;

  reset() {
    this.result = null;
  }

  present(outputPort: GetSponsorshipPricingResult): void {
    this.result = {
      entityType: outputPort.entityType,
      entityId: outputPort.entityId,
      pricing: outputPort.pricing.map(item => ({
        id: item.id,
        level: item.level,
        price: item.price,
        currency: item.currency,
      })),
    };
  }

  getViewModel(): GetEntitySponsorshipPricingResultDTO | null {
    return this.result;
  }

  get viewModel(): GetEntitySponsorshipPricingResultDTO {
    if (!this.result) throw new Error('Presenter not presented');
    return this.result;
  }
}