Fix React crash in Admin Stats rendering: added fieldVal helper to securely extract strings from Baserow objects (like Modus/Fragenset).

This commit is contained in:
2026-04-22 17:11:42 +02:00
parent 2c352b2392
commit c1b93e3ab6
+8 -1
View File
@@ -18,6 +18,13 @@ function wsUrl() {
return `${location.protocol === 'https:' ? 'wss:' : 'ws:'}//${location.host}`;
}
function fieldVal(field, fallback) {
if (!field) return fallback || '';
if (typeof field === 'string') return field;
if (typeof field === 'object' && field.value !== undefined) return field.value;
return String(field);
}
/* ================================================================== */
/* Login */
/* ================================================================== */
@@ -149,7 +156,7 @@ function StatsPage() {
const sessions = {};
data.answers.forEach((a) => {
const sid = a['Session_ID'] || 'Unbekannt';
if (!sessions[sid]) sessions[sid] = { modus: a['Modus'], fragenset: a['Fragenset'], date: a['Zeitstempel'], answers: [] };
if (!sessions[sid]) sessions[sid] = { modus: fieldVal(a['Modus'], ''), fragenset: fieldVal(a['Fragenset'], ''), date: a['Zeitstempel'], answers: [] };
sessions[sid].answers.push(a);
});