wip
This commit is contained in:
@@ -1,15 +1,23 @@
|
||||
import type { IRaceRepository } from '../../domain/repositories/IRaceRepository';
|
||||
import type { ILeagueRepository } from '../../domain/repositories/ILeagueRepository';
|
||||
import type { IRacesPagePresenter } from '@gridpilot/racing/application/presenters/IRacesPagePresenter';
|
||||
import type {
|
||||
IRacesPagePresenter,
|
||||
RacesPageResultDTO,
|
||||
RacesPageViewModel,
|
||||
} from '@gridpilot/racing/application/presenters/IRacesPagePresenter';
|
||||
import type { UseCase } from '@gridpilot/shared/application/UseCase';
|
||||
|
||||
export class GetRacesPageDataUseCase {
|
||||
export class GetRacesPageDataUseCase
|
||||
implements UseCase<void, RacesPageResultDTO, RacesPageViewModel, IRacesPagePresenter>
|
||||
{
|
||||
constructor(
|
||||
private readonly raceRepository: IRaceRepository,
|
||||
private readonly leagueRepository: ILeagueRepository,
|
||||
public readonly presenter: IRacesPagePresenter,
|
||||
) {}
|
||||
|
||||
async execute(): Promise<void> {
|
||||
async execute(_input: void, presenter: IRacesPagePresenter): Promise<void> {
|
||||
presenter.reset();
|
||||
|
||||
const [allRaces, allLeagues] = await Promise.all([
|
||||
this.raceRepository.findAll(),
|
||||
this.leagueRepository.findAll(),
|
||||
@@ -33,6 +41,10 @@ export class GetRacesPageDataUseCase {
|
||||
isPast: race.isPast(),
|
||||
}));
|
||||
|
||||
this.presenter.present(races);
|
||||
const dto: RacesPageResultDTO = {
|
||||
races,
|
||||
};
|
||||
|
||||
presenter.present(dto);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user