code quality
This commit is contained in:
@@ -2,6 +2,7 @@ import { useInject } from '@/lib/di/hooks/useInject';
|
||||
import { enhanceQueryResult } from '@/lib/di/hooks/useReactQueryWithApiError';
|
||||
import { DRIVER_SERVICE_TOKEN } from '@/lib/di/tokens';
|
||||
import { ApiError } from '@/lib/gateways/api/base/ApiError';
|
||||
import type { ProfileViewData } from '@/lib/view-data/ProfileViewData';
|
||||
import { DriverProfileViewModel, type DriverProfileViewModelData } from '@/lib/view-models/DriverProfileViewModel';
|
||||
import { useQuery, UseQueryOptions } from '@tanstack/react-query';
|
||||
|
||||
@@ -25,13 +26,13 @@ export function useDriverProfile(
|
||||
driver: dto.currentDriver ? {
|
||||
id: dto.currentDriver.id,
|
||||
name: dto.currentDriver.name,
|
||||
countryCode: dto.currentDriver.countryCode || '',
|
||||
countryFlag: dto.currentDriver.countryFlag || '',
|
||||
countryCode: dto.currentDriver.country || '',
|
||||
countryFlag: '',
|
||||
avatarUrl: dto.currentDriver.avatarUrl || '',
|
||||
bio: dto.currentDriver.bio || null,
|
||||
iracingId: dto.currentDriver.iracingId || null,
|
||||
joinedAtLabel: dto.currentDriver.joinedAt || '',
|
||||
globalRankLabel: dto.currentDriver.globalRank || '',
|
||||
globalRankLabel: dto.currentDriver.globalRank?.toString() || '',
|
||||
} : {
|
||||
id: '',
|
||||
name: '',
|
||||
@@ -44,8 +45,8 @@ export function useDriverProfile(
|
||||
globalRankLabel: '',
|
||||
},
|
||||
stats: dto.stats ? {
|
||||
ratingLabel: dto.stats.rating || '',
|
||||
globalRankLabel: dto.stats.globalRank || '',
|
||||
ratingLabel: dto.stats.rating?.toString() || '',
|
||||
globalRankLabel: dto.stats.overallRank?.toString() || '',
|
||||
totalRacesLabel: dto.stats.totalRaces?.toString() || '',
|
||||
winsLabel: dto.stats.wins?.toString() || '',
|
||||
podiumsLabel: dto.stats.podiums?.toString() || '',
|
||||
@@ -85,14 +86,6 @@ export function useDriverProfile(
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user