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

  function getEquipmentItemById(id: string) {
    return useNuxtApp().$api<Record<string, any>>(
      `/api/hygiene-checkout-items/id/${id}`,
      {
        method: "GET",
      },
    );
  }

  function equipmentItems(site: string, payload: TEquipmentItemCreate) {
    return useNuxtApp().$api<Record<string, any>>(
      `/api/hygiene-checkout-items/site/${site}/batch`,
      {
        method: "POST",
        body: payload,
      },
    );
  }

  function approveItem(id: string) {
    return useNuxtApp().$api<Record<string, any>>(
      `/api/hygiene-checkout-items/id/${id}/approve`,
      {
        method: "PATCH",
      },
    );
  }

  function disapproveItem(id: string, remarks: string) {
    return useNuxtApp().$api<Record<string, any>>(
      `/api/hygiene-checkout-items/id/${id}/disapprove`,
      {
        method: "PATCH",
        body: { remarks },
      },
    );
  }
  return {
    getEquipmentItems,
    getEquipmentItemById,
    equipmentItems,
    approveItem,
    disapproveItem,
  };
}
