import type { Sponsor } from '@core/racing/domain/entities/sponsor/Sponsor';
import { GetSponsorOutputDTO } from '../dtos/GetSponsorOutputDTO';

export class GetSponsorPresenter {
  private result: GetSponsorOutputDTO | null = null;

  reset() {
    this.result = null;
  }

  present(sponsor: Sponsor) {
    if (!sponsor) {
      this.result = null;
      return;
    }

    this.result = {
      sponsor: {
        id: sponsor.id.toString(),
        name: sponsor.name.toString(),
        ...(sponsor.logoUrl !== undefined ? { logoUrl: sponsor.logoUrl.toString() } : {}),
        ...(sponsor.websiteUrl !== undefined ? { websiteUrl: sponsor.websiteUrl.toString() } : {}),
      },
    } as GetSponsorOutputDTO;
  }

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

  get viewModel(): GetSponsorOutputDTO | null {
    return this.result;
  }
}
