view data fixes
Some checks failed
Contract Testing / contract-snapshot (pull_request) Has been cancelled
Contract Testing / contract-tests (pull_request) Has been cancelled

This commit is contained in:
2026-01-25 00:12:30 +01:00
parent 1b0a1f4aee
commit 6c07abe5e7
37 changed files with 400 additions and 185 deletions

View File

@@ -19,7 +19,83 @@ export function useDriverProfile(
const error = result.getError();
throw new ApiError(error.message, 'SERVER_ERROR', { timestamp: new globalThis.Date().toISOString() });
}
return new DriverProfileViewModel(result.unwrap());
const dto = result.unwrap();
// Convert GetDriverProfileOutputDTO to ProfileViewData
const viewData: ProfileViewData = {
driver: dto.currentDriver ? {
id: dto.currentDriver.id,
name: dto.currentDriver.name,
countryCode: dto.currentDriver.countryCode || '',
countryFlag: dto.currentDriver.countryFlag || '',
avatarUrl: dto.currentDriver.avatarUrl || '',
bio: dto.currentDriver.bio || null,
iracingId: dto.currentDriver.iracingId || null,
joinedAtLabel: dto.currentDriver.joinedAt || '',
globalRankLabel: dto.currentDriver.globalRank || '',
} : {
id: '',
name: '',
countryCode: '',
countryFlag: '',
avatarUrl: '',
bio: null,
iracingId: null,
joinedAtLabel: '',
globalRankLabel: '',
},
stats: dto.stats ? {
ratingLabel: dto.stats.rating || '',
globalRankLabel: dto.stats.globalRank || '',
totalRacesLabel: dto.stats.totalRaces?.toString() || '',
winsLabel: dto.stats.wins?.toString() || '',
podiumsLabel: dto.stats.podiums?.toString() || '',
dnfsLabel: dto.stats.dnfs?.toString() || '',
bestFinishLabel: dto.stats.bestFinish?.toString() || '',
worstFinishLabel: dto.stats.worstFinish?.toString() || '',
avgFinishLabel: dto.stats.avgFinish?.toString() || '',
consistencyLabel: dto.stats.consistency?.toString() || '',
percentileLabel: dto.stats.percentile?.toString() || '',
} : null,
teamMemberships: dto.teamMemberships.map(m => ({
teamId: m.teamId,
teamName: m.teamName,
teamTag: m.teamTag || null,
roleLabel: m.role || '',
joinedAtLabel: m.joinedAt || '',
href: `/teams/${m.teamId}`,
})),
extendedProfile: dto.extendedProfile ? {
timezone: dto.extendedProfile.timezone || '',
racingStyle: dto.extendedProfile.racingStyle || '',
favoriteTrack: dto.extendedProfile.favoriteTrack || '',
favoriteCar: dto.extendedProfile.favoriteCar || '',
availableHours: dto.extendedProfile.availableHours || '',
lookingForTeamLabel: dto.extendedProfile.lookingForTeam ? 'Yes' : 'No',
openToRequestsLabel: dto.extendedProfile.openToRequests ? 'Yes' : 'No',
socialHandles: dto.extendedProfile.socialHandles?.map(h => ({
platformLabel: h.platform || '',
handle: h.handle || '',
url: h.url || '',
})) || [],
achievements: dto.extendedProfile.achievements?.map(a => ({
id: a.id,
title: a.title,
description: a.description,
earnedAtLabel: a.earnedAt || '',
icon: a.icon as any,
rarityLabel: a.rarity || '',
})) || [],
friends: dto.extendedProfile.friends?.map(f => ({
id: f.id,
name: f.name,
countryFlag: f.countryFlag || '',
avatarUrl: f.avatarUrl || '',
href: `/drivers/${f.id}`,
})) || [],
friendsCountLabel: dto.extendedProfile.friendsCount?.toString() || '',
} : null,
};
return new DriverProfileViewModel(viewData);
},
enabled: !!driverId,
...options,