mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 13:00:39 +03:00
22 lines
648 B
TypeScript
22 lines
648 B
TypeScript
![]() |
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,
|
||
|
onSettled: async () => await client.invalidateQueries({ queryKey: [authApi.baseKey] })
|
||
|
});
|
||
|
return {
|
||
|
changePassword: (
|
||
|
data: IChangePasswordDTO, //
|
||
|
onSuccess?: () => void
|
||
|
) => mutation.mutate(data, { onSuccess }),
|
||
|
isPending: mutation.isPending,
|
||
|
error: mutation.error,
|
||
|
reset: mutation.reset
|
||
|
};
|
||
|
};
|