refactor core presenters

This commit is contained in:
2025-12-19 19:42:19 +01:00
parent 8116fe888f
commit 94fc538f44
228 changed files with 2817 additions and 3097 deletions

View File

@@ -1,33 +1,33 @@
import { IAllTeamsPresenter, AllTeamsResultDTO, AllTeamsViewModel, TeamListItemViewModel } from '@core/racing/application/presenters/IAllTeamsPresenter';
import { GetAllTeamsOutputPort } from '@core/racing/application/ports/output/GetAllTeamsOutputPort';
import { GetAllTeamsOutputDTO } from '../dtos/GetAllTeamsOutputDTO';
export class AllTeamsPresenter implements IAllTeamsPresenter {
private result: AllTeamsViewModel | null = null;
export class AllTeamsPresenter {
private result: GetAllTeamsOutputDTO | null = null;
reset() {
this.result = null;
}
present(dto: AllTeamsResultDTO) {
const teams: TeamListItemViewModel[] = dto.teams.map(team => ({
id: team.id,
name: team.name,
tag: team.tag,
description: team.description,
memberCount: team.memberCount,
leagues: team.leagues || [],
}));
async present(output: GetAllTeamsOutputPort) {
this.result = {
teams,
totalCount: teams.length,
teams: output.teams.map(team => ({
id: team.id,
name: team.name,
tag: team.tag,
description: team.description,
memberCount: team.memberCount,
leagues: team.leagues || [],
// Note: specialization, region, languages not available in output port
})),
totalCount: output.totalCount || output.teams.length,
};
}
getViewModel(): AllTeamsViewModel | null {
getViewModel(): GetAllTeamsOutputDTO | null {
return this.result;
}
get viewModel(): AllTeamsViewModel {
get viewModel(): GetAllTeamsOutputDTO {
if (!this.result) throw new Error('Presenter not presented');
return this.result;
}