mirror of
https://github.com/GCMatters/hermes.git
synced 2026-02-04 05:30:13 +01:00
przejscie na api
przed rozwaleniem
This commit is contained in:
34
WebApp/wwwroot/js/eventDelete.js
Normal file
34
WebApp/wwwroot/js/eventDelete.js
Normal file
@@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
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.");
|
||||
}
|
||||
}));
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user