mirror of
https://github.com/GCMatters/hermes.git
synced 2026-02-04 13:40:13 +01:00
Trzeba dodać logowanie tak jak reszte(nie wiem gdzie było logowanie ale zaraz się znajdzie)
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
document.addEventListener("DOMContentLoaded", async () => {
|
||
const container = document.getElementById("eventList");
|
||
if (!container) return;
|
||
|
||
try {
|
||
const res = await fetch("/api/events");
|
||
if (!res.ok) throw new Error("Błąd pobierania wydarzeń");
|
||
|
||
const events = await res.json();
|
||
|
||
if (events.length === 0) {
|
||
container.innerHTML = "<p class='text-muted'>Brak wydarzeń do wyświetlenia.</p>";
|
||
return;
|
||
}
|
||
|
||
// Wyczyść kontener przed dodaniem nowych
|
||
container.innerHTML = '';
|
||
|
||
for (const ev of events) {
|
||
const card = document.createElement("div");
|
||
card.className = "event-card filled";
|
||
card.innerHTML = `
|
||
<span>${ev.title}</span>
|
||
<button class="remove-btn delete-btn" data-id="${ev.eventId}">−</button>
|
||
`;
|
||
container.appendChild(card);
|
||
}
|
||
} catch (err) {
|
||
container.innerHTML = `<p class="text-danger">Błąd ładowania danych.</p>`;
|
||
console.error(err);
|
||
}
|
||
}); |