export default function useNFCPatrolTag() {
  function getAll({
    page = 1,
    limit = 10,
    site = "",
  } = {}) {
    return useNuxtApp().$api<Record<string, any>>(`/api/nfc-patrol-tag`, {
      method: "GET",
      query: {
        page,
        limit,
        site,
      },
    });
  }

  function add(value: { site: string; tagID: string; name: string }) {
    return useNuxtApp().$api<Record<string, any>>("/api/nfc-patrol-tag", {
      method: "POST",
      body: {
        site: value.site,
        tagID: value.tagID,
        name: value.name,
      },
    });
  }

  function deleteById(id: string) {
    return useNuxtApp().$api(`/api/nfc-patrol-tag/${id}`, {
      method: "DELETE",
    });
  }

  function updateById(id: string, value: { site: string; tagID: string; name: string; _id?: string; updateType?: string }) {
    return useNuxtApp().$api(`/api/nfc-patrol-tag`, {
      method: "PUT",
      body: {
        name: value.name,
        tagID: value.tagID,
        site: value.site,
        _id: value._id || id,
        updateType: value.updateType || "Edit",
      },
    });
  }

  return {
    getAll,
    add,
    deleteById,
    updateById,
  };
}
