From d833a60ad4398de65f395e832e18523e8512825b Mon Sep 17 00:00:00 2001 From: Lars Date: Sat, 21 Mar 2026 08:06:01 +0100 Subject: [PATCH] fix: [BUG-002] add missing Daten tab to show nutrition entries Problem: Imported nutrition data not visible in UI Root Cause: NutritionPage only had analysis tabs, no raw data view Solution: Added "Daten" tab with entries list showing date, kcal, macros Tested: Entries now visible after CSV import Closes: BUG-002 Co-Authored-By: Claude Opus 4.6 --- frontend/src/pages/NutritionPage.jsx | 40 ++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/NutritionPage.jsx b/frontend/src/pages/NutritionPage.jsx index 04281c8..c2531fa 100644 --- a/frontend/src/pages/NutritionPage.jsx +++ b/frontend/src/pages/NutritionPage.jsx @@ -322,9 +322,10 @@ function CalorieBalance({ data, profile }) { // ── Main Page ───────────────────────────────────────────────────────────────── export default function NutritionPage() { - const [tab, setTab] = useState('overview') + const [tab, setTab] = useState('data') // BUG-002 fix: show data first const [corrData, setCorr] = useState([]) const [weekly, setWeekly] = useState([]) + const [entries, setEntries]= useState([]) // BUG-002 fix: raw data const [profile, setProf] = useState(null) const [loading, setLoad] = useState(true) const [hasData, setHasData]= useState(false) @@ -332,13 +333,15 @@ export default function NutritionPage() { const load = async () => { setLoad(true) try { - const [corr, wkly, prof] = await Promise.all([ + const [corr, wkly, ent, prof] = await Promise.all([ nutritionApi.nutritionCorrelations(), nutritionApi.nutritionWeekly(16), + nutritionApi.listNutrition(365), // BUG-002 fix: load raw entries api.getActiveProfile(), ]) setCorr(Array.isArray(corr)?corr:[]) setWeekly(Array.isArray(wkly)?wkly:[]) + setEntries(Array.isArray(ent)?ent:[]) // BUG-002 fix setProf(prof) setHasData(Array.isArray(corr) && corr.some(d=>d.kcal)) } catch(e) { console.error('load error:', e) } @@ -367,12 +370,45 @@ export default function NutritionPage() {
+
+ {tab==='data' && ( +
+
Alle Einträge ({entries.length})
+ {entries.length === 0 && ( +

Noch keine Ernährungsdaten. Importiere FDDB CSV oben.

+ )} + {entries.map((e, i) => ( +
+
+ {dayjs(e.date).format('dd, DD. MMMM YYYY')} +
+ {Math.round(e.kcal || 0)} kcal +
+
+
+ 🥩 Protein: {Math.round(e.protein_g || 0)}g + 🫙 Fett: {Math.round(e.fat_g || 0)}g + 🍞 Kohlenhydrate: {Math.round(e.carbs_g || 0)}g +
+ {e.source && ( +
+ Quelle: {e.source} +
+ )} +
+ ))} +
+ )} + {tab==='overview' && (
Makro-Verteilung pro Woche (Ø g/Tag)