export default function useOnlineForm() {
  function getAll({
    page = 1,
    search = "",
    limit = 10,
    status = "active",
    site = "",
  } = {}) {
    return useNuxtApp().$api<Record<string, any>>(`/api/online-forms`, {
      method: "GET",
      query: {
        page,
        search,
        limit,
        status,
        site,
      },
    });
  }
  function add(value: any) {
    return useNuxtApp().$api<Record<string, any>>("/api/online-forms", {
      method: "POST",
      body: value,
    });
  }
  function getOnlineFormById(id: string) {
    return useNuxtApp().$api<Record<string, any>>(
      `/api/online-forms/id/${id}`,
      {
        method: "GET",
      }
    );
  }
  function updateOnlineFormById(id: string, value: any) {
    return useNuxtApp().$api<Record<string, any>>(
      `/api/online-forms/id/${id}`,
      {
        method: "PUT",
        body: value,
      }
    );
  }
  function deleteOnlineFormById(id: string) {
    return useNuxtApp().$api(`/api/online-forms/deleted/online-form`, {
      method: "PUT",
      query: { id },
    });
  }
  function getAllBySiteId(
    siteId: string,
    { page = 1, search = "", limit = 10, status = "active" }
  ) {
    return useNuxtApp().$api<Record<string, any>>(
      `/api/online-forms/site/${siteId}`,
      {
        method: "GET",
        query: {
          page,
          search,
          limit,
          status,
        },
      }
    );
  }
  return {
    getAll,
    add,
    getOnlineFormById,
    updateOnlineFormById,
    deleteOnlineFormById,
    getAllBySiteId,
  };
}
