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:
+8
-1
@@ -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);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user