import { RequestAvatarGenerationOutput } from '../dto/MediaDto';
import type { IRequestAvatarGenerationPresenter, RequestAvatarGenerationResultDTO } from '@core/media/application/presenters/IRequestAvatarGenerationPresenter';

export class RequestAvatarGenerationPresenter implements IRequestAvatarGenerationPresenter {
  private result: RequestAvatarGenerationOutput | null = null;

  reset() {
    this.result = null;
  }

  present(dto: RequestAvatarGenerationResultDTO) {
    this.result = {
      success: dto.status === 'completed',
      requestId: dto.requestId,
      avatarUrls: dto.avatarUrls,
      errorMessage: dto.errorMessage,
    };
  }

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

  getViewModel(): RequestAvatarGenerationOutput {
    return this.viewModel;
  }
}