import { AuthActionCheckResponse } from "./auth-actions";
import { useAuth } from "./use-auth";

export const useIsLoggedIn = (queryOptions?: UseQueryOptions<AuthActionCheckResponse>) => {
  const keys = useQueryKey();
  const { check } = useAuth();

  const result = useQuery<AuthActionCheckResponse>({
    queryKey: keys().auth().action("check").get(),
    queryFn: check,
    retry: false,
    ...queryOptions,
  });

  return result;
};
