export default function useVerification() {
  function getVerifications({
    status = "pending",
    type = "user-invite",
    search = "",
    page = 1,
    email = "",
    app = "",
    siteId = "",
    orgId = "",
    limit = 20,
  } = {}): Promise<{
    items: TMiniVerification[];
    pages: number;
    pageRange: string;
  }> {
    return useNuxtApp().$api("/api/verifications", {
      method: "GET",
      query: { status, search, page, type, email, app, siteId, orgId, limit },
    });
  }

  function cancelUserInvitation(id: string) {
    console.log("Calling API to cancel:", id);
    return useNuxtApp().$api<Record<string, any>>(
      `/api/verifications/${id}/cancel`,
      {
        method: "PUT",
      }
    );
  }

  return {
    getVerifications,
    cancelUserInvitation,
  };
}
