34 lines
815 B
TypeScript
34 lines
815 B
TypeScript
import type {
|
|
IAllTeamsPresenter,
|
|
TeamListItemViewModel,
|
|
AllTeamsViewModel,
|
|
AllTeamsResultDTO,
|
|
} from '@gridpilot/racing/application/presenters/IAllTeamsPresenter';
|
|
|
|
export class AllTeamsPresenter implements IAllTeamsPresenter {
|
|
private viewModel: AllTeamsViewModel | null = null;
|
|
|
|
reset(): void {
|
|
this.viewModel = null;
|
|
}
|
|
|
|
present(input: AllTeamsResultDTO): void {
|
|
const teamItems: TeamListItemViewModel[] = input.teams.map((team) => ({
|
|
id: team.id,
|
|
name: team.name,
|
|
tag: team.tag,
|
|
description: team.description,
|
|
memberCount: team.memberCount ?? 0,
|
|
leagues: team.leagues,
|
|
}));
|
|
|
|
this.viewModel = {
|
|
teams: teamItems,
|
|
totalCount: teamItems.length,
|
|
};
|
|
}
|
|
|
|
getViewModel(): AllTeamsViewModel | null {
|
|
return this.viewModel;
|
|
}
|
|
} |