Files
gridpilot.gg/apps/api/src/domain/league/presenters/GetLeagueOwnerSummaryPresenter.ts

30 lines
1010 B
TypeScript

import type { UseCaseOutputPort } from '@core/shared/application';
import type { GetLeagueOwnerSummaryResult } from '@core/racing/application/use-cases/GetLeagueOwnerSummaryUseCase';
import { LeagueOwnerSummaryDTO } from '../dtos/LeagueOwnerSummaryDTO';
export class GetLeagueOwnerSummaryPresenter implements UseCaseOutputPort<GetLeagueOwnerSummaryResult> {
private result: LeagueOwnerSummaryDTO | null = null;
reset() {
this.result = null;
}
present(output: GetLeagueOwnerSummaryResult) {
this.result = {
driver: {
id: output.owner.id,
iracingId: output.owner.iracingId.toString(),
name: output.owner.name.toString(),
country: output.owner.country.toString(),
joinedAt: output.owner.joinedAt.toDate().toISOString(),
...(output.owner.bio ? { bio: output.owner.bio.toString() } : {}),
},
rating: output.rating,
rank: output.rank,
};
}
getViewModel(): LeagueOwnerSummaryDTO | null {
return this.result;
}
}