2025-01-27 15:03:48 +03:00
|
|
|
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,
|
2025-01-29 14:52:07 +03:00
|
|
|
onSettled: () => client.invalidateQueries({ queryKey: [authApi.baseKey] })
|
2025-01-27 15:03:48 +03:00
|
|
|
});
|
|
|
|
return {
|
2025-02-11 20:16:11 +03:00
|
|
|
changePassword: (data: IChangePasswordDTO) => mutation.mutateAsync(data),
|
2025-01-27 15:03:48 +03:00
|
|
|
isPending: mutation.isPending,
|
|
|
|
error: mutation.error,
|
|
|
|
reset: mutation.reset
|
|
|
|
};
|
|
|
|
};
|