refactor
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { ITeamsLeaderboardPresenter, TeamsLeaderboardResultDTO, TeamsLeaderboardViewModel } 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 any, // Cast to match the view model
|
||||
recruitingCount: dto.recruitingCount,
|
||||
groupsBySkillLevel: {
|
||||
beginner: [],
|
||||
intermediate: [],
|
||||
advanced: [],
|
||||
pro: [],
|
||||
},
|
||||
topTeams: dto.teams.slice(0, 10) as any,
|
||||
};
|
||||
}
|
||||
|
||||
getViewModel(): TeamsLeaderboardViewModel | null {
|
||||
return this.result;
|
||||
}
|
||||
|
||||
get viewModel(): TeamsLeaderboardViewModel {
|
||||
if (!this.result) throw new Error('Presenter not presented');
|
||||
return this.result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user