import { refreshToken } from "@/lib/api/auth/refresh-token"
import { useAuthStore } from "@/zustand/authStore"
import { useMutation } from "@tanstack/react-query"

export const useOtpRequest = () => {
  useMutation({
        mutationFn: refreshToken,
        onSuccess: (data) => {
            useAuthStore.getState().setToken(data.accessToken)
        },
        onError: () => {
          useAuthStore.getState().logout();
        }
    })
}
