import { AuthActionCheckResponse, useAuth } from "@/lib/hooks";
import { UseQueryOptions, useQuery } from "@tanstack/react-query";
import { useQueryKey } from "../useQueryKey";

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;
};
