website refactor
This commit is contained in:
@@ -10,7 +10,13 @@ export function useFileProtest(
|
||||
const raceService = useInject(RACE_SERVICE_TOKEN);
|
||||
|
||||
return useMutation<void, ApiError, FileProtestCommandDTO>({
|
||||
mutationFn: (command) => raceService.fileProtest(command),
|
||||
mutationFn: async (command) => {
|
||||
const result = await raceService.fileProtest(command);
|
||||
if (result.isErr()) {
|
||||
const error = result.getError();
|
||||
throw new ApiError(error.message, 'SERVER_ERROR', { timestamp: new Date().toISOString() });
|
||||
}
|
||||
},
|
||||
...options,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,13 @@ export function useRegisterForRace(
|
||||
const raceService = useInject(RACE_SERVICE_TOKEN);
|
||||
|
||||
return useMutation<void, ApiError, RegisterForRaceParams>({
|
||||
mutationFn: (params) => raceService.registerForRace(params.raceId, params.leagueId, params.driverId),
|
||||
mutationFn: async (params) => {
|
||||
const result = await raceService.registerForRace(params.raceId, params.leagueId, params.driverId);
|
||||
if (result.isErr()) {
|
||||
const error = result.getError();
|
||||
throw new ApiError(error.message, 'SERVER_ERROR', { timestamp: new Date().toISOString() });
|
||||
}
|
||||
},
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -14,7 +14,13 @@ export function useWithdrawFromRace(
|
||||
const raceService = useInject(RACE_SERVICE_TOKEN);
|
||||
|
||||
return useMutation<void, ApiError, WithdrawFromRaceParams>({
|
||||
mutationFn: (params) => raceService.withdrawFromRace(params.raceId, params.driverId),
|
||||
mutationFn: async (params) => {
|
||||
const result = await raceService.withdrawFromRace(params.raceId, params.driverId);
|
||||
if (result.isErr()) {
|
||||
const error = result.getError();
|
||||
throw new ApiError(error.message, 'SERVER_ERROR', { timestamp: new Date().toISOString() });
|
||||
}
|
||||
},
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user