ConceptPortal-public/rsconcept/frontend/src/features/auth/backend/useChangePassword.tsx
Ivan 536705c00b
Some checks are pending
Frontend CI / build (22.x) (push) Waiting to run
F: Upgrade to tailwind 4. Fix type imports
2025-02-21 21:15:05 +03:00

22 lines
672 B
TypeScript

import { useMutation, useQueryClient } from '@tanstack/react-query';
import { KEYS } from '@/backend/configuration';
import { authApi } from './api';
import { type IChangePasswordDTO } from './types';
export const useChangePassword = () => {
const client = useQueryClient();
const mutation = useMutation({
mutationKey: [KEYS.auth, '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
};
};