import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
import type { GetTeamMembershipResult } from '@core/racing/application/use-cases/GetTeamMembershipUseCase';
import type { GetTeamMembershipOutputDTO } from '../dtos/GetTeamMembershipOutputDTO';

export class TeamMembershipPresenter implements UseCaseOutputPort<GetTeamMembershipResult> {
  private result: GetTeamMembershipOutputDTO | null = null;

  reset(): void {
    this.result = null;
  }

  present(result: GetTeamMembershipResult): void {
    this.result = result.membership;
  }

  getResponseModel(): GetTeamMembershipOutputDTO | null {
    return this.result;
  }

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