website refactor
This commit is contained in:
@@ -13,10 +13,17 @@ export function useFindDriverById(
|
||||
|
||||
const queryResult = useQuery({
|
||||
queryKey: ['driver', driverId],
|
||||
queryFn: () => driverService.findById(driverId),
|
||||
queryFn: async () => {
|
||||
const result = await driverService.findById(driverId);
|
||||
if (result.isErr()) {
|
||||
const error = result.getError();
|
||||
throw new ApiError(error.message, 'SERVER_ERROR', { timestamp: new Date().toISOString() });
|
||||
}
|
||||
return result.unwrap();
|
||||
},
|
||||
enabled: !!driverId,
|
||||
...options,
|
||||
});
|
||||
|
||||
return enhanceQueryResult(queryResult);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user