mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-08 00:02:15 +01:00
move user delete to api endpoint
This commit is contained in:
committed by
Constantin Graf
parent
fe4e903203
commit
d0334bd730
@@ -57,6 +57,29 @@ export function useUpdateUserMutation() {
|
||||
});
|
||||
}
|
||||
|
||||
export function useDeleteUserMutation() {
|
||||
const { addNotification } = useNotificationsStore();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (userId: string) => {
|
||||
try {
|
||||
await api.deleteUser(undefined, { params: { user: userId } });
|
||||
} catch (error) {
|
||||
if (!axios.isAxiosError(error) || error.response?.status !== 422) {
|
||||
addNotification(
|
||||
'error',
|
||||
'Failed to delete account',
|
||||
axios.isAxiosError(error)
|
||||
? (error.response?.data?.message ?? 'Please try again later.')
|
||||
: 'Please try again later.'
|
||||
);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useResendUserEmailVerificationMutation() {
|
||||
const { handleApiRequestNotifications } = useNotificationsStore();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user