Switch termine loading from static CSV to dynamic API for instant updates

This commit is contained in:
Torsten Schulz (local)
2025-10-21 16:21:01 +02:00
parent 4af0b2a448
commit c35cdcfcc9
17 changed files with 801 additions and 727 deletions

View File

@@ -87,50 +87,11 @@ const formatMonth = (dateString) => {
const loadTermine = async () => {
try {
console.log('Lade Termine...')
const response = await fetch('/data/termine.csv')
console.log('Response:', response)
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`)
}
const csv = await response.text()
console.log('CSV Text:', csv)
// Vereinfachter CSV-Parser
const lines = csv.split('\n').filter(line => line.trim() !== '')
console.log('CSV Lines:', lines)
if (lines.length < 2) {
console.log('Keine Datenzeilen gefunden')
return
}
termine.value = lines.slice(1).map((line, index) => {
// Entferne Anführungszeichen und teile bei Kommas
const cleanLine = line.replace(/"/g, '')
const values = cleanLine.split(',')
if (values.length < 4) {
console.log(`Zeile ${index + 2} hat zu wenige Werte:`, values)
return null
}
const termin = {
datum: values[0].trim(),
titel: values[1].trim(),
beschreibung: values[2].trim(),
kategorie: values[3].trim()
}
console.log(`Termin ${index + 1}:`, termin)
return termin
}).filter(termin => termin !== null)
console.log('Alle geparsten Termine:', termine.value)
const response = await $fetch('/api/termine')
termine.value = response.termine || []
} catch (error) {
console.error('Fehler beim Laden der Termine:', error)
termine.value = []
}
}