import { LeagueAdminDTO } from '../dtos/LeagueAdminDTO';
import { LeagueJoinRequestDTO } from '../dtos/LeagueJoinRequestDTO';
import { LeagueOwnerSummaryDTO } from '../dtos/LeagueOwnerSummaryDTO';
import { LeagueConfigFormModelDTO } from '../dtos/LeagueConfigFormModelDTO';
import { LeagueAdminProtestsDTO } from '../dtos/LeagueAdminProtestsDTO';
import { LeagueSeasonSummaryDTO } from '../dtos/LeagueSeasonSummaryDTO';

export class LeagueAdminPresenter {
  private result: LeagueAdminDTO | null = null;

  reset() {
    this.result = null;
  }

  present(data: {
    joinRequests: unknown[];
    ownerSummary: unknown;
    config: unknown;
    protests: unknown;
    seasons: unknown[];
  }) {
    this.result = {
      joinRequests: data.joinRequests as LeagueJoinRequestDTO[],
      ownerSummary: data.ownerSummary as LeagueOwnerSummaryDTO | null,
      config: { form: data.config as LeagueConfigFormModelDTO | null },
      protests: data.protests as LeagueAdminProtestsDTO,
      seasons: data.seasons as LeagueSeasonSummaryDTO[],
    };
  }

  getViewModel(): LeagueAdminDTO {
    if (!this.result) throw new Error('Presenter not presented');
    return this.result;
  }
}