export function creatorLinksPage() {
  Array.from(document.querySelectorAll(".link-request-card")).forEach(card => {
    card.querySelector(".control > .approve").addEventListener("click", async (_e) => {
      await approveLinkRequest(card.dataset["id"]);
      card.remove();
    });
    card.querySelector(".control > .reject").addEventListener("click", async (_e) => {
      await rejectLinkRequest(card.dataset["id"]);
      card.remove();
    });
  })
}

async function approveLinkRequest(requestId) {
  let resp = await fetch(`/creator_link_requests/${requestId}/approve`, { method: "POST" });
  let json = await resp.json();
}

async function rejectLinkRequest(requestId) {
  let resp = await fetch(`/creator_link_requests/${requestId}/reject`, { method: "POST" });
  let json = await resp.json();
}
