document.addEventListener("DOMContentLoaded", () => { document.body.addEventListener("click", async (e) => { const target = e.target as HTMLElement; if (!target.matches(".delete-btn")) return; const id = target.getAttribute("data-id"); if (!id) return; const confirmed = confirm("Na pewno chcesz usunąć to wydarzenie?"); if (!confirmed) return; const response = await fetch(`/api/events/${id}`, { method: "DELETE" }); if (response.ok) { const card = target.closest(".col"); if (card) card.remove(); } else { alert("Nie udało się usunąć wydarzenia."); } }); });