Update Hero component to dynamically display years since founding; enhance TermineVorschau component with improved date and time formatting, and add Uhrzeit column in the CMS for better event management. Refactor API to handle new fields and improve data handling in CSV exports.

This commit is contained in:
Torsten Schulz (local)
2025-11-05 10:36:58 +01:00
parent 21044c6c34
commit 36400304a4
16 changed files with 913 additions and 292 deletions

View File

@@ -50,9 +50,10 @@ export async function readTermine() {
termine.push({
id: randomUUID(), // Generate ID on-the-fly for editing
datum: values[0],
titel: values[1],
beschreibung: values[2],
kategorie: values[3]
uhrzeit: values[1] || '',
titel: values[2] || '',
beschreibung: values[3] || '',
kategorie: values[4] || 'Sonstiges'
})
}
}
@@ -70,21 +71,23 @@ export async function readTermine() {
// Write array of objects to CSV
export async function writeTermine(termine) {
try {
let csv = '"datum","titel","beschreibung","kategorie"\n'
let csv = '"datum","uhrzeit","titel","beschreibung","kategorie"\n'
for (const termin of termine) {
const datum = termin.datum || ''
const uhrzeit = termin.uhrzeit || ''
const titel = termin.titel || ''
const beschreibung = termin.beschreibung || ''
const kategorie = termin.kategorie || ''
// Escape quotes in values
const escapedDatum = datum.replace(/"/g, '""')
const escapedUhrzeit = uhrzeit.replace(/"/g, '""')
const escapedTitel = titel.replace(/"/g, '""')
const escapedBeschreibung = beschreibung.replace(/"/g, '""')
const escapedKategorie = kategorie.replace(/"/g, '""')
csv += `"${escapedDatum}","${escapedTitel}","${escapedBeschreibung}","${escapedKategorie}"\n`
csv += `"${escapedDatum}","${escapedUhrzeit}","${escapedTitel}","${escapedBeschreibung}","${escapedKategorie}"\n`
}
await fs.writeFile(TERMINE_FILE, csv, 'utf-8')
@@ -102,6 +105,7 @@ export async function saveTermin(terminData) {
// Always add as new (CSV doesn't have persistent IDs)
const newTermin = {
datum: terminData.datum,
uhrzeit: terminData.uhrzeit || '',
titel: terminData.titel,
beschreibung: terminData.beschreibung || '',
kategorie: terminData.kategorie || 'Sonstiges'
@@ -122,6 +126,7 @@ export async function deleteTermin(terminData) {
termine = termine.filter(t =>
!(t.datum === terminData.datum &&
(t.uhrzeit || '') === (terminData.uhrzeit || '') &&
t.titel === terminData.titel &&
t.beschreibung === terminData.beschreibung &&
t.kategorie === terminData.kategorie)