import { DriverProfileViewDataBuilder } from '@/lib/builders/view-data/DriverProfileViewDataBuilder'; import { useInject } from '@/lib/di/hooks/useInject'; import { DRIVER_SERVICE_TOKEN } from '@/lib/di/tokens'; import { ApiError } from '@/lib/gateways/api/base/ApiError'; import type { GetDriverProfileOutputDTO } from '@/lib/types/generated/GetDriverProfileOutputDTO'; import type { DriverProfileViewData } from '@/lib/view-data/DriverProfileViewData'; import { useMutation, UseMutationOptions } from '@tanstack/react-query'; export function useUpdateDriverProfile( options?: Omit, 'mutationFn'> ) { const driverService = useInject(DRIVER_SERVICE_TOKEN); return useMutation({ 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 DriverProfileViewDataBuilder.build({ teamMemberships: [], socialSummary: { friends: [], friendsCount: 0 }, } as unknown as GetDriverProfileOutputDTO); }, ...options, }); }