import type { GetSeasonSponsorshipsResult } from '@core/racing/application/use-cases/GetSeasonSponsorshipsUseCase';
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
import { SponsorshipDetailDTO } from '../../sponsor/dtos/SponsorshipDetailDTO';
import { GetSeasonSponsorshipsOutputDTO } from '../dtos/GetSeasonSponsorshipsOutputDTO';

export class GetSeasonSponsorshipsPresenter implements UseCaseOutputPort<GetSeasonSponsorshipsResult> {
  private result: GetSeasonSponsorshipsOutputDTO | null = null;

  reset() {
    this.result = null;
  }

  present(result: GetSeasonSponsorshipsResult): void {
    this.result = {
      sponsorships: result.sponsorships.map(s => ({
        id: s.id,
        leagueId: s.leagueId.toString(),
        leagueName: s.leagueName.toString(),
        seasonId: s.seasonId,
        seasonName: s.seasonName,
        seasonStartDate: s.seasonStartDate,
        seasonEndDate: s.seasonEndDate,
        tier: s.tier as 'main' | 'secondary',
        status: s.status as 'pending' | 'active' | 'expired' | 'cancelled',
        pricing: s.pricing,
        platformFee: s.platformFee,
        netAmount: s.netAmount,
        metrics: s.metrics,
        createdAt: s.createdAt,
        activatedAt: s.activatedAt,
      } as SponsorshipDetailDTO)),
    };
  }

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