mirror of
https://github.com/GCMatters/hermes.git
synced 2026-02-04 21:50:12 +01:00
Wersja probna
powinno cos dzialac
This commit is contained in:
@@ -1,24 +1,25 @@
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const deleteButtons = document.querySelectorAll(".delete-btn");
|
||||
document.body.addEventListener("click", async (e) => {
|
||||
const target = e.target as HTMLElement;
|
||||
|
||||
deleteButtons.forEach(button => {
|
||||
button.addEventListener("click", async () => {
|
||||
const id = (button as HTMLButtonElement).dataset.id;
|
||||
if (!id) return;
|
||||
if (!target.matches(".delete-btn")) return;
|
||||
|
||||
const confirmed = confirm("Na pewno chcesz usunąć to wydarzenie?");
|
||||
if (!confirmed) return;
|
||||
const id = target.getAttribute("data-id");
|
||||
if (!id) return;
|
||||
|
||||
const response = await fetch(`/api/events/${id}`, {
|
||||
method: "DELETE"
|
||||
});
|
||||
const confirmed = confirm("Na pewno chcesz usunąć to wydarzenie?");
|
||||
if (!confirmed) return;
|
||||
|
||||
if (response.ok) {
|
||||
const row = button.closest("tr");
|
||||
if (row) row.remove();
|
||||
} else {
|
||||
alert("Nie udało się usunąć wydarzenia.");
|
||||
}
|
||||
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.");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user