diff --git a/frontend/src/calendar.jsx b/frontend/src/calendar.jsx index 84c8be3..aebc194 100644 --- a/frontend/src/calendar.jsx +++ b/frontend/src/calendar.jsx @@ -93,31 +93,41 @@ export default function CalendarWidget() { const [selected, setSelected] = useState(null); // date object const [errors, setErrors] = useState([]); + const [debug, setDebug] = useState([]); // Load all feeds const loadFeeds = async (feedList) => { - if (!feedList.length) { setEvents([]); return; } + if (!feedList.length) { setEvents([]); setDebug(['Keine Feeds konfiguriert']); return; } setLoading(true); setErrors([]); const all = []; const errs = []; + const dbg = []; + dbg.push(`Feeds: ${feedList.length}`); for (const f of feedList) { try { + dbg.push(`Lade: ${f.name} (${f.url.slice(0,50)}…)`); const res = await fetch(`/api/calendar/fetch?url=${encodeURIComponent(f.url)}`, { headers: { Authorization: `Bearer ${localStorage.getItem('sk_token')}` } }); + dbg.push(`HTTP: ${res.status}`); if (res.ok) { const text = await res.text(); + dbg.push(`Bytes: ${text.length}, VCALENDAR: ${text.includes('BEGIN:VCALENDAR')}, VEVENTs: ${(text.match(/BEGIN:VEVENT/g)||[]).length}`); const evs = parseIcal(text).map(e => ({ ...e, color: f.color, feedName: f.name })); + dbg.push(`Geparst: ${evs.length} Termine`); + if (evs.length > 0) dbg.push(`Erstes: ${evs[0].summary} @ ${evs[0].dtstart}`); all.push(...evs); } else { const d = await res.json().catch(()=>({error:'Unbekannter Fehler'})); errs.push(`${f.name}: ${d.error}`); + dbg.push(`Fehler: ${d.error}`); } - } catch(e) { errs.push(`${f.name}: ${e.message}`); } + } catch(e) { errs.push(`${f.name}: ${e.message}`); dbg.push(`Exception: ${e.message}`); } } setEvents(all); setErrors(errs); + setDebug(dbg); setLoading(false); }; @@ -258,6 +268,17 @@ export default function CalendarWidget() { Noch keine Kalender abonniert. Füge Kalender in den Einstellungen hinzu. )} + + {/* Debug Panel */} + {debug.length > 0 && ( +
+
DEBUG
+ {debug.map((d,i) => ( +
{d}
+ ))} +
+ )} )}