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

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

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

  return data;
};

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