mirror of
https://github.com/GCMatters/hermes.git
synced 2026-02-04 13:40:13 +01:00
Wersja probna
powinno cos dzialac
This commit is contained in:
@@ -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.");
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user