Portal/rsconcept/frontend/src/backend/auth/useChangePassword.tsx

22 lines
648 B
TypeScript
Raw Normal View History

2025-01-21 20:33:05 +03:00
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { authApi, IChangePasswordDTO } from './api';
export const useChangePassword = () => {
2025-01-23 19:41:31 +03:00
const client = useQueryClient();
2025-01-21 20:33:05 +03:00
const mutation = useMutation({
mutationKey: ['change-password'],
mutationFn: authApi.changePassword,
2025-01-23 19:41:31 +03:00
onSettled: async () => await client.invalidateQueries({ queryKey: [authApi.baseKey] })
2025-01-21 20:33:05 +03:00
});
return {
2025-01-23 19:41:31 +03:00
changePassword: (
data: IChangePasswordDTO, //
onSuccess?: () => void
) => mutation.mutate(data, { onSuccess }),
2025-01-21 20:33:05 +03:00
isPending: mutation.isPending,
error: mutation.error,
reset: mutation.reset
};
};