Files
gridpilot.gg/apps/api/src/modules/league/presenters/GetLeagueSeasonsPresenter.ts
2025-12-16 00:57:31 +01:00

27 lines
859 B
TypeScript

import { IGetLeagueSeasonsPresenter, GetLeagueSeasonsResultDTO, GetLeagueSeasonsViewModel } from '@gridpilot/racing/application/presenters/IGetLeagueSeasonsPresenter';
export class GetLeagueSeasonsPresenter implements IGetLeagueSeasonsPresenter {
private result: GetLeagueSeasonsViewModel | null = null;
reset() {
this.result = null;
}
present(dto: GetLeagueSeasonsResultDTO) {
const seasons = dto.seasons.map(season => ({
seasonId: season.id,
name: season.name,
status: season.status,
startDate: season.startDate,
endDate: season.endDate,
isPrimary: season.isPrimary,
isParallelActive: season.isParallelActive,
}));
this.result = { seasons };
}
getViewModel(): GetLeagueSeasonsViewModel {
if (!this.result) throw new Error('Presenter not presented');
return this.result;
}
}