ConceptPortal-public/rsconcept/frontend/src/features/auth/backend/useChangePassword.tsx
Ivan e53157aa31 R: Rework all mutations to mutateAsync
Fixes problem with mutations callback not being triggered in dialogs
2025-02-11 20:16:11 +03:00

19 lines
581 B
TypeScript

import { useMutation, useQueryClient } from '@tanstack/react-query';
import { authApi, IChangePasswordDTO } from './api';
export const useChangePassword = () => {
const client = useQueryClient();
const mutation = useMutation({
mutationKey: ['change-password'],
mutationFn: authApi.changePassword,
onSettled: () => client.invalidateQueries({ queryKey: [authApi.baseKey] })
});
return {
changePassword: (data: IChangePasswordDTO) => mutation.mutateAsync(data),
isPending: mutation.isPending,
error: mutation.error,
reset: mutation.reset
};
};