refactor
This commit is contained in:
@@ -1,23 +1,17 @@
|
||||
import type { IRaceRepository } from '../../domain/repositories/IRaceRepository';
|
||||
import type { ILeagueRepository } from '../../domain/repositories/ILeagueRepository';
|
||||
import type {
|
||||
IRacesPagePresenter,
|
||||
RacesPageResultDTO,
|
||||
RacesPageViewModel,
|
||||
} from '@core/racing/application/presenters/IRacesPagePresenter';
|
||||
import type { UseCase } from '@core/shared/application/UseCase';
|
||||
import type { RacesPageResultDTO } from '@core/racing/application/presenters/IRacesPagePresenter';
|
||||
import type { AsyncUseCase } from '@core/shared/application/AsyncUseCase';
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
|
||||
export class GetRacesPageDataUseCase
|
||||
implements UseCase<void, RacesPageResultDTO, RacesPageViewModel, IRacesPagePresenter>
|
||||
{
|
||||
export class GetRacesPageDataUseCase implements AsyncUseCase<void, RacesPageResultDTO, 'NO_ERROR'> {
|
||||
constructor(
|
||||
private readonly raceRepository: IRaceRepository,
|
||||
private readonly leagueRepository: ILeagueRepository,
|
||||
) {}
|
||||
|
||||
async execute(_input: void, presenter: IRacesPagePresenter): Promise<void> {
|
||||
presenter.reset();
|
||||
|
||||
async execute(): Promise<Result<RacesPageResultDTO, ApplicationErrorCode<'NO_ERROR'>>> {
|
||||
const [allRaces, allLeagues] = await Promise.all([
|
||||
this.raceRepository.findAll(),
|
||||
this.leagueRepository.findAll(),
|
||||
@@ -45,6 +39,6 @@ export class GetRacesPageDataUseCase
|
||||
races,
|
||||
};
|
||||
|
||||
presenter.present(dto);
|
||||
return Result.ok(dto);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user