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

20 lines
607 B
TypeScript
Raw Normal View History

2025-01-21 20:33:05 +03:00
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { authApi } from './api';
import { IChangePasswordDTO } from './types';
2025-01-21 20:33:05 +03:00
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,
onSettled: () => client.invalidateQueries({ queryKey: [authApi.baseKey] })
2025-01-21 20:33:05 +03:00
});
return {
2025-02-11 20:15:34 +03:00
changePassword: (data: IChangePasswordDTO) => mutation.mutateAsync(data),
2025-01-21 20:33:05 +03:00
isPending: mutation.isPending,
error: mutation.error,
reset: mutation.reset
};
};