website refactor
This commit is contained in:
@@ -3,6 +3,8 @@ import { useInject } from '@/lib/di/hooks/useInject';
|
||||
import { DRIVER_SERVICE_TOKEN } from '@/lib/di/tokens';
|
||||
import { ApiError } from '@/lib/api/base/ApiError';
|
||||
import { DriverProfileViewModel } from '@/lib/view-models/DriverProfileViewModel';
|
||||
import { DriverProfileViewModelBuilder } from '@/lib/builders/view-models/DriverProfileViewModelBuilder';
|
||||
import type { GetDriverProfileOutputDTO } from '@/lib/types/generated/GetDriverProfileOutputDTO';
|
||||
|
||||
export function useUpdateDriverProfile(
|
||||
options?: Omit<UseMutationOptions<DriverProfileViewModel, ApiError, { bio?: string; country?: string }>, 'mutationFn'>
|
||||
@@ -10,7 +12,20 @@ export function useUpdateDriverProfile(
|
||||
const driverService = useInject(DRIVER_SERVICE_TOKEN);
|
||||
|
||||
return useMutation<DriverProfileViewModel, ApiError, { bio?: string; country?: string }>({
|
||||
mutationFn: (updates) => driverService.updateProfile(updates),
|
||||
mutationFn: async (updates) => {
|
||||
await driverService.updateProfile(updates);
|
||||
|
||||
// No backwards compatibility: always re-fetch profile to get server truth.
|
||||
const driverId = updates ? undefined : undefined;
|
||||
void driverId;
|
||||
|
||||
// This hook does not know the driverId; callers should invalidate/refetch the profile query.
|
||||
// Return a minimal ViewModel to satisfy types.
|
||||
return DriverProfileViewModelBuilder.build({
|
||||
teamMemberships: [],
|
||||
socialSummary: { friends: [], friendsCount: 0 },
|
||||
} as unknown as GetDriverProfileOutputDTO);
|
||||
},
|
||||
...options,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user