import type { LeagueScoringPresetProvider } from '../ports/LeagueScoringPresetProvider';
import type { LeagueScoringPresetsResultDTO } from '../presenters/ILeagueScoringPresetsPresenter';
import type { AsyncUseCase } from '@core/shared/application/AsyncUseCase';
import { Result } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';

/**
 * Use Case for listing league scoring presets.
 * Orchestrates domain logic and returns result.
 */
export class ListLeagueScoringPresetsUseCase
  implements AsyncUseCase<void, LeagueScoringPresetsResultDTO, 'NO_ERROR'>
{
  constructor(private readonly presetProvider: LeagueScoringPresetProvider) {}

  async execute(): Promise<Result<LeagueScoringPresetsResultDTO, ApplicationErrorCode<'NO_ERROR'>>> {
    const presets = await this.presetProvider.listPresets();

    const dto: LeagueScoringPresetsResultDTO = {
      presets,
    };

    return Result.ok(dto);
  }
}