35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
|
|
import type { GetAllTeamsResult } from '@core/racing/application/use-cases/GetAllTeamsUseCase';
|
|
import { GetAllTeamsOutputDTO } from '../dtos/GetAllTeamsOutputDTO';
|
|
|
|
export class AllTeamsPresenter implements UseCaseOutputPort<GetAllTeamsResult> {
|
|
private model: GetAllTeamsOutputDTO | null = null;
|
|
|
|
reset(): void {
|
|
this.model = null;
|
|
}
|
|
|
|
present(result: GetAllTeamsResult): void {
|
|
this.model = {
|
|
teams: result.teams.map(team => ({
|
|
id: team.id,
|
|
name: team.name.toString(),
|
|
tag: team.tag.toString(),
|
|
description: team.description?.toString() || '',
|
|
memberCount: team.memberCount,
|
|
leagues: team.leagues?.map(l => l.toString()) || [],
|
|
// Note: specialization, region, languages not available in output
|
|
})),
|
|
totalCount: result.totalCount ?? result.teams.length,
|
|
};
|
|
}
|
|
|
|
getResponseModel(): GetAllTeamsOutputDTO | null {
|
|
return this.model;
|
|
}
|
|
|
|
get responseModel(): GetAllTeamsOutputDTO {
|
|
if (!this.model) throw new Error('Presenter not presented');
|
|
return this.model;
|
|
}
|
|
} |