import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
import type { CreateTeamResult } from '@core/racing/application/use-cases/CreateTeamUseCase';
import type { CreateTeamOutputDTO } from '../dtos/CreateTeamOutputDTO';

export class CreateTeamPresenter implements UseCaseOutputPort<CreateTeamResult> {
  private model: CreateTeamOutputDTO | null = null;

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

  present(result: CreateTeamResult): void {
    this.model = {
      id: result.team.id,
      success: true,
    };
  }

  getResponseModel(): CreateTeamOutputDTO | null {
    return this.model;
  }

  get responseModel(): CreateTeamOutputDTO {
    if (!this.model) {
      throw new Error('Presenter not presented');
    }

    return this.model;
  }
}
