Feature: Termine-Anzeige auf der Startseite

- Neue CSV-Datei backend/data/termine.csv für Termine-Speicherung
- Backend-Controller und Router für /api/termine Endpoint
- TermineWidget Component zur Anzeige von bevorstehenden Terminen
- Integration in LoggedInView (Startseite für eingeloggte User)
- Zeigt Datum, Titel, Beschreibung, Ort und Uhrzeit an
- Sortiert nach Datum, filtert automatisch vergangene Termine
This commit is contained in:
Torsten Schulz (local)
2025-10-20 22:27:35 +02:00
parent 47f5def67c
commit ccd8bfba0d
6 changed files with 259 additions and 5 deletions

View File

@@ -0,0 +1,43 @@
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
class TermineController {
async getTermine(req, res) {
try {
const csvPath = path.join(__dirname, '../data/termine.csv');
const csvContent = fs.readFileSync(csvPath, 'utf-8');
const lines = csvContent.trim().split('\n');
const headers = lines[0].split(',');
const termine = lines.slice(1).map(line => {
const values = line.split(',');
const termin = {};
headers.forEach((header, index) => {
termin[header] = values[index] || '';
});
return termin;
});
// Sortiere nach Datum
termine.sort((a, b) => new Date(a.datum) - new Date(b.datum));
// Filtere nur zukünftige Termine
const heute = new Date();
heute.setHours(0, 0, 0, 0);
const zukuenftigeTermine = termine.filter(t => new Date(t.datum) >= heute);
res.status(200).json(zukuenftigeTermine);
} catch (error) {
console.error('Error reading termine.csv:', error);
res.status(500).json({ error: 'Could not load termine' });
}
}
}
export default new TermineController();