mirror of
https://github.com/GCMatters/hermes.git
synced 2026-02-04 05:30:13 +01:00
Wersja probna
powinno cos dzialac
This commit is contained in:
49
WebApp/wwwroot/js/eventList.js
Normal file
49
WebApp/wwwroot/js/eventList.js
Normal file
@@ -0,0 +1,49 @@
|
||||
"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", () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const container = document.getElementById("eventList");
|
||||
if (!container)
|
||||
return;
|
||||
try {
|
||||
const res = yield fetch("/api/events");
|
||||
if (!res.ok)
|
||||
throw new Error("Błąd pobierania wydarzeń");
|
||||
const events = yield res.json();
|
||||
if (events.length === 0) {
|
||||
container.innerHTML = "<p class='text-muted'>Brak wydarzeń do wyświetlenia.</p>";
|
||||
return;
|
||||
}
|
||||
for (const ev of events) {
|
||||
const card = document.createElement("div");
|
||||
card.className = "col";
|
||||
card.innerHTML = `
|
||||
<div class="card shadow-sm h-100">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">${ev.title}</h5>
|
||||
<p class="card-text">
|
||||
<strong>Miejsce:</strong> ${ev.location}<br/>
|
||||
<strong>Data:</strong> ${new Date(ev.eventDate).toLocaleString()}<br/>
|
||||
<strong>Organizacja ID:</strong> ${ev.organisationId}
|
||||
</p>
|
||||
<button class="btn btn-outline-danger delete-btn" data-id="${ev.eventId}">
|
||||
🗑️ Usuń
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
container.appendChild(card);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
container.innerHTML = `<p class="text-danger">Błąd ładowania danych.</p>`;
|
||||
console.error(err);
|
||||
}
|
||||
}));
|
||||
Reference in New Issue
Block a user