Files
gridpilot.gg/apps/api/src/domain/team/presenters/TeamsLeaderboardPresenter.ts
2025-12-19 01:22:45 +01:00

32 lines
976 B
TypeScript

import { ITeamsLeaderboardPresenter, TeamsLeaderboardResultDTO, TeamsLeaderboardViewModel, TeamLeaderboardItemViewModel } from '@core/racing/application/presenters/ITeamsLeaderboardPresenter';
export class TeamsLeaderboardPresenter implements ITeamsLeaderboardPresenter {
private result: TeamsLeaderboardViewModel | null = null;
reset() {
this.result = null;
}
present(dto: TeamsLeaderboardResultDTO) {
this.result = {
teams: dto.teams as TeamLeaderboardItemViewModel[],
recruitingCount: dto.recruitingCount,
groupsBySkillLevel: {
beginner: [],
intermediate: [],
advanced: [],
pro: [],
},
topTeams: (dto.teams as TeamLeaderboardItemViewModel[]).slice(0, 10),
};
}
getViewModel(): TeamsLeaderboardViewModel | null {
return this.result;
}
get viewModel(): TeamsLeaderboardViewModel {
if (!this.result) throw new Error('Presenter not presented');
return this.result;
}
}