export default function useStock() {
  function getStockBySupply(
    site: string,
    supply: string,
    page = 1,
    search = "",
    limit = 10,
    serviceType = ""
  ) {
    return useNuxtApp().$api<Record<string, any>>(
      `/api/hygiene-stocks/site/${site}/supply/${supply}`,
      { method: "GET", query: { page, search, limit, serviceType } }
    );
  }

  function createStock(site: string, id: string, payload: TStockCreate) {
    return useNuxtApp().$api<Record<string, any>>(
      `/api/hygiene-stocks/site/${site}/supply/${id}`,
      {
        method: "POST",
        body: {
          qty: payload.qty,
          remarks: payload.remarks,
          serviceType: payload.serviceType,
        },
      }
    );
  }



  return {
    createStock,
    getStockBySupply,
  };
}
