Wersja probna

powinno cos dzialac
This commit is contained in:
Witkopawel
2025-04-30 12:40:59 +02:00
parent 74b69f045d
commit 470ce72b6a
12 changed files with 332 additions and 141 deletions

View File

@@ -9,26 +9,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
document.addEventListener("DOMContentLoaded", () => {
const deleteButtons = document.querySelectorAll(".delete-btn");
deleteButtons.forEach(button => {
button.addEventListener("click", () => __awaiter(void 0, void 0, void 0, function* () {
const id = button.dataset.id;
if (!id)
return;
const confirmed = confirm("Na pewno chcesz usunąć to wydarzenie?");
if (!confirmed)
return;
const response = yield fetch(`/api/events/${id}`, {
method: "DELETE"
});
if (response.ok) {
const row = button.closest("tr");
if (row)
row.remove();
}
else {
alert("Nie udało się usunąć wydarzenia.");
}
}));
});
document.body.addEventListener("click", (e) => __awaiter(void 0, void 0, void 0, function* () {
const target = e.target;
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 = yield 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.");
}
}));
});