This commit is contained in:
2025-12-21 19:53:22 +01:00
parent f2d8a23583
commit 3c64f328e2
105 changed files with 3191 additions and 1706 deletions

View File

@@ -1,47 +1,61 @@
import type { ProfileOverviewOutputPort } from '@core/racing/application/ports/output/ProfileOverviewOutputPort';
import type {
GetProfileOverviewResult,
} from '@core/racing/application/use-cases/GetProfileOverviewUseCase';
import type { GetDriverProfileOutputDTO } from '../dtos/GetDriverProfileOutputDTO';
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
export class DriverProfilePresenter {
private result: GetDriverProfileOutputDTO | null = null;
export class DriverProfilePresenter
implements UseCaseOutputPort<GetProfileOverviewResult>
{
private responseModel: GetDriverProfileOutputDTO | null = null;
reset(): void {
this.result = null;
}
present(output: ProfileOverviewOutputPort): void {
this.result = {
currentDriver: output.driver
present(result: GetProfileOverviewResult): void {
this.responseModel = {
currentDriver: result.driverInfo
? {
id: output.driver.id,
name: output.driver.name,
country: output.driver.country,
avatarUrl: output.driver.avatarUrl,
iracingId: output.driver.iracingId,
joinedAt: output.driver.joinedAt.toISOString(),
rating: output.driver.rating,
globalRank: output.driver.globalRank,
consistency: output.driver.consistency,
bio: output.driver.bio,
totalDrivers: output.driver.totalDrivers,
id: result.driverInfo.driver.id,
name: result.driverInfo.driver.name.toString(),
country: result.driverInfo.driver.country.toString(),
avatarUrl: this.getAvatarUrl(result.driverInfo.driver.id) || '',
iracingId: result.driverInfo.driver.iracingId.toString(),
joinedAt: result.driverInfo.driver.joinedAt.toDate().toISOString(),
rating: result.driverInfo.rating,
globalRank: result.driverInfo.globalRank,
consistency: result.driverInfo.consistency,
bio: result.driverInfo.driver.bio?.toString() || null,
totalDrivers: result.driverInfo.totalDrivers,
}
: null,
stats: output.stats,
finishDistribution: output.finishDistribution,
teamMemberships: output.teamMemberships.map(membership => ({
teamId: membership.teamId,
teamName: membership.teamName,
teamTag: membership.teamTag,
role: membership.role,
joinedAt: membership.joinedAt.toISOString(),
isCurrent: membership.isCurrent,
stats: result.stats,
finishDistribution: result.finishDistribution,
teamMemberships: result.teamMemberships.map(membership => ({
teamId: membership.team.id,
teamName: membership.team.name.toString(),
teamTag: membership.team.tag.toString(),
role: membership.membership.role,
joinedAt: membership.membership.joinedAt.toISOString(),
isCurrent: true, // TODO: check membership status
})),
socialSummary: output.socialSummary,
extendedProfile: output.extendedProfile,
socialSummary: {
friendsCount: result.socialSummary.friendsCount,
friends: result.socialSummary.friends.map(friend => ({
id: friend.id,
name: friend.name.toString(),
country: friend.country.toString(),
avatarUrl: '', // TODO: get avatar
})),
},
extendedProfile: result.extendedProfile as any,
};
}
get viewModel(): GetDriverProfileOutputDTO {
if (!this.result) throw new Error('Presenter not presented');
return this.result;
getResponseModel(): GetDriverProfileOutputDTO {
if (!this.responseModel) throw new Error('Presenter not presented');
return this.responseModel;
}
private getAvatarUrl(driverId: string): string | undefined {
// Avatar resolution is delegated to infrastructure; keep as-is for now.
return undefined;
}
}