import { GetSponsorOutputDTO } from '../dtos/GetSponsorOutputDTO';

interface GetSponsorOutputPort {
  sponsor: {
    id: string;
    name: string;
    logoUrl?: string;
    websiteUrl?: string;
  };
}

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

  reset() {
    this.result = null;
  }

  present(output: GetSponsorOutputPort | null) {
    if (!output) {
      this.result = null;
      return;
    }

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

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

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