feat: Phase 0c Frontend Phase 1 - Nutrition + Recovery Charts
Deploy Development / deploy (push) Successful in 46s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s

- Create NutritionCharts component (E1-E5)
  - Energy Balance Timeline
  - Macro Distribution (Pie)
  - Protein Adequacy Timeline
  - Nutrition Consistency Score

- Create RecoveryCharts component (R1-R5)
  - Recovery Score Timeline
  - HRV/RHR vs Baseline (dual-axis)
  - Sleep Duration + Quality (dual-axis)
  - Sleep Debt Accumulation
  - Vital Signs Matrix (horizontal bar)

- Add 9 chart API functions to api.js
  - 4 nutrition endpoints (E1-E5)
  - 5 recovery endpoints (R1-R5)

- Integrate into History page
  - Add NutritionCharts to existing Nutrition tab
  - Create new Recovery tab with RecoveryCharts
  - Period selector controls chart timeframe

Charts use Recharts (existing dependency)
All charts display Chart.js-compatible data from backend
Confidence handling: Show 'Nicht genug Daten' message

Files:
+ frontend/src/components/NutritionCharts.jsx (329 lines)
+ frontend/src/components/RecoveryCharts.jsx (342 lines)
M frontend/src/utils/api.js (+14 functions)
M frontend/src/pages/History.jsx (+22 lines, new Recovery tab)
This commit is contained in:
Lars committed 2026-03-29 07:02:54 +02:00
1 parent f81171a1f5
commit d4500ca00c
4 files changed
+650

No files matched your search

+32
View File
@@ -12,6 +12,8 @@ import { getBfCategory } from '../utils/calc'
import { getInterpretation, getStatusColor, getStatusBg } from '../utils/interpret'
import Markdown from '../utils/Markdown'
import TrainingTypeDistribution from '../components/TrainingTypeDistribution'
import NutritionCharts from '../components/NutritionCharts'
import RecoveryCharts from '../components/RecoveryCharts'
import dayjs from 'dayjs'
import 'dayjs/locale/de'
dayjs.locale('de')
@@ -581,6 +583,13 @@ function NutritionSection({ nutrition, weights, profile, insights, onRequest, lo
<div style={{fontSize:12,fontWeight:600,color:'var(--text3)',marginBottom:8}}>BEWERTUNG</div>
{macroRules.map((item,i)=><RuleCard key={i} item={item}/>)}
</div>
{/* New Nutrition Charts (Phase 0c) */}
<div style={{marginTop:16}}>
<div style={{fontSize:12,fontWeight:600,color:'var(--text3)',marginBottom:8}}>📊 DETAILLIERTE CHARTS</div>
<NutritionCharts days={period === 9999 ? 90 : period} />
</div>
<InsightBox insights={insights} slugs={filterActiveSlugs(['ernaehrung'])} onRequest={onRequest} loading={loadingSlug}/>
</div>
)
@@ -915,10 +924,32 @@ function PhotoGrid() {
}
// ── Main ──────────────────────────────────────────────────────────────────────
// ── Recovery Section ──────────────────────────────────────────────────────────
function RecoverySection({ insights, onRequest, loadingSlug, filterActiveSlugs }) {
const [period, setPeriod] = useState(28)
return (
<div>
<SectionHeader title="😴 Erholung & Vitalwerte" to="/vitals" toLabel="Daten"/>
<PeriodSelector value={period} onChange={setPeriod}/>
<div style={{marginBottom:12,fontSize:13,color:'var(--text2)',lineHeight:1.6}}>
Erholung, Schlaf, HRV, Ruhepuls und weitere Vitalwerte im Überblick.
</div>
{/* Recovery Charts (Phase 0c) */}
<RecoveryCharts days={period === 9999 ? 90 : period} />
<InsightBox insights={insights} slugs={filterActiveSlugs(['gesundheit'])} onRequest={onRequest} loading={loadingSlug}/>
</div>
)
}
const TABS = [
{ id:'body', label:'⚖️ Körper' },
{ id:'nutrition', label:'🍽️ Ernährung' },
{ id:'activity', label:'🏋️ Aktivität' },
{ id:'recovery', label:'😴 Erholung' },
{ id:'correlation', label:'🔗 Korrelation' },
{ id:'photos', label:'📷 Fotos' },
]
@@ -994,6 +1025,7 @@ export default function History() {
{tab==='body' && <BodySection weights={weights} calipers={calipers} circs={circs} profile={profile} {...sp}/>}
{tab==='nutrition' && <NutritionSection nutrition={nutrition} weights={weights} profile={profile} {...sp}/>}
{tab==='activity' && <ActivitySection activities={activities} globalQualityLevel={activeProfile?.quality_filter_level} {...sp}/>}
{tab==='recovery' && <RecoverySection {...sp}/>}
{tab==='correlation' && <CorrelationSection corrData={corrData} profile={profile} {...sp}/>}
{tab==='photos' && <PhotoGrid/>}
</div>