Files
gridpilot.gg/core/racing/application/use-cases/GetLeagueSeasonsUseCase.ts
2025-12-16 13:53:23 +01:00

22 lines
987 B
TypeScript

import type { ISeasonRepository } from '../../domain/repositories/ISeasonRepository';
import type { IGetLeagueSeasonsPresenter, GetLeagueSeasonsResultDTO, GetLeagueSeasonsViewModel } from '../presenters/IGetLeagueSeasonsPresenter';
import type { UseCase } from '@core/shared/application/UseCase';
export interface GetLeagueSeasonsUseCaseParams {
leagueId: string;
}
export interface GetLeagueSeasonsResultDTO {
seasons: unknown[];
}
export class GetLeagueSeasonsUseCase implements UseCase<GetLeagueSeasonsUseCaseParams, GetLeagueSeasonsResultDTO, GetLeagueSeasonsViewModel, IGetLeagueSeasonsPresenter> {
constructor(private readonly seasonRepository: ISeasonRepository) {}
async execute(params: GetLeagueSeasonsUseCaseParams, presenter: IGetLeagueSeasonsPresenter): Promise<void> {
const seasons = await this.seasonRepository.findByLeagueId(params.leagueId);
const dto: GetLeagueSeasonsResultDTO = { seasons };
presenter.reset();
presenter.present(dto);
}
}