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

export function getinventoryCheck(data: any) {
    return queryOptions({
        queryKey: ["getInvCheck"],
        queryFn: () => fetchStockSilo(data),
        //enabled:
        staleTime: 1000,
        refetchInterval: 1000 * 60 * 15,
        refetchOnWindowFocus: true,
    });
}

const fetchStockSilo = async (info: any) => {
    //console.log("What tpye of info:", info);
    const { data } = await axios.post(`/api/logistics/cyclecountcheck`, {
        age: info.age ? parseInt(info.age) : null,
        type: "",
    });

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