import { queryOptions } from "@tanstack/react-query";
import axios from "axios";

export function getStockSilo() {
	return queryOptions({
		queryKey: ["getSiloData"],
		queryFn: () => fetchStockSilo(),
		//enabled: !!token, // Prevents query if token is null
		staleTime: 1000,
		//refetchInterval: 2 * 2000,
		refetchOnWindowFocus: true,
	});
}

const fetchStockSilo = async () => {
	const { data } = await axios.get(`/lst/old/api/logistics/getstocksilo`, {
		headers: {
			"Content-Type": "application/json",
		},
	});

	// if we are not localhost ignore the devDir setting.
	//const url: string = window.location.host.split(":")[0];
	return data.data ?? [];
};
