add: reset password functionality
This commit is contained in:
@@ -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 }
|
||||
}
|
||||
Reference in New Issue
Block a user