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

22 lines
667 B
TypeScript
Raw Normal View History

2025-01-21 20:33:05 +03:00
import { useMutation, useQueryClient } from '@tanstack/react-query';
2025-02-19 19:15:57 +03:00
import { KEYS } from '@/backend/configuration';
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({
2025-02-19 19:15:57 +03:00
mutationKey: [KEYS.auth, 'change-password'],
2025-01-21 20:33:05 +03:00
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
};
};