import { useQuery } from "@tanstack/react-query";
import axiosInstance from "@/lib/axios";

// Fetcher that accepts `input` as a parameter
const fetchUserBioData = async (user?: string) => {
  const userId = localStorage.getItem("userId");

  const { data } = await axiosInstance.get(`/users/${userId || user}/bio-data`);

  return data;
};

export const useGetUserBioData = (userId?: string) => {
  return useQuery({
    queryKey: ["BioDataData", userId],
    queryFn: () => fetchUserBioData(userId),
    staleTime: 1000 * 60 * 10,
    refetchOnWindowFocus: false,
    enabled: true,
  });
};
