44 lines
1.7 KiB
JavaScript
44 lines
1.7 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.initEventsSection = initEventsSection;
|
|
const api_js_1 = require("../../services/api.js");
|
|
const toast_js_1 = require("../../ui/toast.js");
|
|
async function initEventsSection(guildId) {
|
|
const section = document.getElementById('section-events');
|
|
if (!section)
|
|
return;
|
|
section.innerHTML = '<p class="muted">Lade Events...</p>';
|
|
try {
|
|
const data = await api_js_1.api.events(guildId);
|
|
const events = data?.events || data || [];
|
|
section.innerHTML = '<h2 class="section-title">Events</h2>';
|
|
if (!events.length) {
|
|
section.innerHTML += '<div class="empty-state">Keine Events geplant.</div>';
|
|
return;
|
|
}
|
|
const list = document.createElement('div');
|
|
list.className = 'ticket-list';
|
|
events.forEach((ev) => {
|
|
const item = document.createElement('div');
|
|
item.className = 'ticket-item';
|
|
item.innerHTML = `
|
|
<div class="row" style="justify-content:space-between;">
|
|
<div>
|
|
<div style="font-weight:750;">${ev.title || 'Event'}</div>
|
|
<div class="muted">${ev.date || ''}</div>
|
|
</div>
|
|
<span class="pill">${ev.status || 'open'}</span>
|
|
</div>
|
|
<div class="muted">${ev.description || ''}</div>
|
|
`;
|
|
list.appendChild(item);
|
|
});
|
|
section.appendChild(list);
|
|
}
|
|
catch (err) {
|
|
console.error(err);
|
|
section.innerHTML = '<div class="empty-state">Events konnten nicht geladen werden.</div>';
|
|
(0, toast_js_1.showToast)('Fehler beim Laden der Events', true);
|
|
}
|
|
}
|