Lekkie zmiany

Trzeba dodać logowanie tak jak reszte(nie wiem gdzie było logowanie ale zaraz się znajdzie)
This commit is contained in:
Witkopawel
2025-04-30 16:21:51 +02:00
parent 071626366e
commit 0e14821cec
9 changed files with 131 additions and 161 deletions

View File

@@ -9,26 +9,35 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
document.addEventListener("DOMContentLoaded", () => {
// Obsługuje kliknięcie na przycisk "Usuń"
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");
return; // Sprawdza, czy kliknięto przycisk "Usuń"
const id = target.getAttribute("data-id"); // Pobiera ID wydarzenia
if (!id)
return;
const confirmed = confirm("Na pewno chcesz usunąć to wydarzenie?");
const confirmed = confirm("Na pewno chcesz usunąć to wydarzenie?"); // Potwierdzenie usunięcia
if (!confirmed)
return;
const response = yield fetch(`/api/events/${id}`, {
method: "DELETE"
});
if (response.ok) {
const card = target.closest(".col");
if (card)
card.remove();
try {
// Wysyła żądanie DELETE do API
const response = yield fetch(`/api/events/${id}`, {
method: "DELETE"
});
if (response.ok) {
// Usuwa kartę z DOM (bez przeładowania strony)
const card = target.closest(".event-card");
if (card)
card.remove();
}
else {
alert("Błąd podczas usuwania wydarzenia.");
}
}
else {
alert("Nie udało się usunąć wydarzenia.");
catch (err) {
alert("Błąd połączenia z serwerem.");
console.error(err);
}
}));
});