add: reset password functionality

This commit is contained in:
Mahyar Khanbolooki
2025-07-01 23:50:17 +03:30
parent 48c458f012
commit 5056e2233a
3 changed files with 55 additions and 2 deletions
+20
View File
@@ -0,0 +1,20 @@
import { useQueryClient } from '@tanstack/react-query'
import { useAuthStore } from '@/zustand/authStore'
import { resetPassword, ResetPasswordRequestModel } from '@/lib/api/auth/reset-password';
export const useResetPassword = () =>
{
const queryClient = useQueryClient()
const run = (model: ResetPasswordRequestModel) =>
queryClient.fetchQuery({
queryKey: ['resetPassword', model],
queryFn: () => resetPassword(model),
}).then(() => {
useAuthStore.getState().logout();
}).catch((ex) => {
throw ex;
})
return { run }
}