presenter refactoring

This commit is contained in:
2025-12-20 17:06:11 +01:00
parent 92be9d2e1b
commit e9d6f90bb2
109 changed files with 4159 additions and 1283 deletions

View File

@@ -2,22 +2,46 @@ import { GetLeagueScheduleOutputPort } from '@core/racing/application/ports/outp
import { LeagueScheduleDTO } from '../dtos/LeagueScheduleDTO';
import { RaceDTO } from '../../race/dtos/RaceDTO';
export function mapGetLeagueScheduleOutputPortToDTO(output: GetLeagueScheduleOutputPort, leagueName?: string): LeagueScheduleDTO {
return {
races: output.races.map<RaceDTO>(race => ({
export class LeagueSchedulePresenter {
private result: LeagueScheduleDTO | null = null;
reset() {
this.result = null;
}
present(output: GetLeagueScheduleOutputPort, leagueName?: string) {
this.result = {
races: output.races.map<RaceDTO>(race => ({
id: race.id,
name: race.name,
date: race.scheduledAt.toISOString(),
leagueName,
})),
};
}
getViewModel(): LeagueScheduleDTO | null {
return this.result;
}
}
export class LeagueRacesPresenter {
private result: RaceDTO[] | null = null;
reset() {
this.result = null;
}
present(output: GetLeagueScheduleOutputPort, leagueName?: string) {
this.result = output.races.map<RaceDTO>(race => ({
id: race.id,
name: race.name,
date: race.scheduledAt.toISOString(),
leagueName,
})),
};
}
}));
}
export function mapGetLeagueScheduleOutputPortToRaceDTOs(output: GetLeagueScheduleOutputPort, leagueName?: string): RaceDTO[] {
return output.races.map<RaceDTO>(race => ({
id: race.id,
name: race.name,
date: race.scheduledAt.toISOString(),
leagueName,
}));
getViewModel(): RaceDTO[] | null {
return this.result;
}
}