Portal/rsconcept/frontend/src/backend/auth/useChangePassword.tsx
Ivan 76aee5bea7
Some checks failed
Frontend CI / build (22.x) (push) Has been cancelled
F: Implement react-query pt2
2025-01-21 20:33:05 +03:00

19 lines
625 B
TypeScript

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