Switch termine loading from static CSV to dynamic API for instant updates
This commit is contained in:
@@ -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 = []
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user