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

export const useIsLoggedIn = (
  params?: UseMutationOptions<AuthActionCheckResponse, Error, unknown>
) => {
  const keys = useQueryKey();
  const { check } = useAuth();

  return useMutation({
    mutationKey: keys().auth().action("check").get(),
    mutationFn: check,
    ...params,
  });
};
