feat: update app version to 0.9t and enhance nutrition visualization
- Bumped application version to 0.9t and updated changelog with new features. - Integrated new chart payloads for energy balance, protein adequacy, and nutrition adherence to optimize data retrieval and reduce HTTP requests. - Updated NutritionCharts component to utilize prefetched chart payloads, improving loading efficiency and user experience. - Refactored History page to pass chart payloads, enhancing the visualization of nutrition trends without additional requests.
This commit is contained in:
1 parent
da1e0410cc
commit
3f6673b636
6 files changed
+485
-405
No files matched your search
@@ -205,12 +205,14 @@ export function WeeklyMacroDistributionPanel({ macroWeeklyData, loading, error }
|
||||
|
||||
/**
|
||||
* Nutrition Charts (E1–E5). Verlauf: `showWeeklyMacroDistribution={false}` wenn E3 separat (z. B. neben Donut) gerendert wird.
|
||||
* @param {object} [prefetchedChartPayloads] — aus GET /charts/nutrition-history-viz (`chart_payloads`): E1/E2/E4 ohne Extra-Requests (Phase C).
|
||||
*/
|
||||
export default function NutritionCharts({
|
||||
days = 28,
|
||||
showWeeklyMacroDistribution = true,
|
||||
/** Verlauf: E5-Kachel liegt in nutrition-history-viz KPIs — doppelte Karte ausblenden */
|
||||
hideEnergyAvailabilityCard = false,
|
||||
prefetchedChartPayloads = null,
|
||||
}) {
|
||||
const [energyData, setEnergyData] = useState(null)
|
||||
const [proteinData, setProteinData] = useState(null)
|
||||
@@ -226,20 +228,44 @@ export default function NutritionCharts({
|
||||
|
||||
useEffect(() => {
|
||||
loadCharts()
|
||||
}, [days, showWeeklyMacroDistribution, hideEnergyAvailabilityCard])
|
||||
}, [days, showWeeklyMacroDistribution, hideEnergyAvailabilityCard, prefetchedChartPayloads])
|
||||
|
||||
const loadCharts = async () => {
|
||||
const tasks = [
|
||||
loadEnergyBalance(),
|
||||
loadProteinAdequacy(),
|
||||
loadAdherence(),
|
||||
]
|
||||
const p = prefetchedChartPayloads
|
||||
const tasks = []
|
||||
|
||||
if (p?.energy_balance) {
|
||||
setEnergyData(p.energy_balance)
|
||||
setLoading((l) => ({ ...l, energy: false }))
|
||||
setErrors((e) => ({ ...e, energy: null }))
|
||||
} else {
|
||||
tasks.push(loadEnergyBalance())
|
||||
}
|
||||
|
||||
if (p?.protein_adequacy) {
|
||||
setProteinData(p.protein_adequacy)
|
||||
setLoading((l) => ({ ...l, protein: false }))
|
||||
setErrors((e) => ({ ...e, protein: null }))
|
||||
} else {
|
||||
tasks.push(loadProteinAdequacy())
|
||||
}
|
||||
|
||||
if (showWeeklyMacroDistribution) {
|
||||
tasks.push(loadMacroWeekly())
|
||||
}
|
||||
|
||||
if (p?.nutrition_adherence) {
|
||||
setAdherenceData(p.nutrition_adherence)
|
||||
setLoading((l) => ({ ...l, adherence: false }))
|
||||
setErrors((e) => ({ ...e, adherence: null }))
|
||||
} else {
|
||||
tasks.push(loadAdherence())
|
||||
}
|
||||
|
||||
if (!hideEnergyAvailabilityCard) {
|
||||
tasks.push(loadWarning())
|
||||
}
|
||||
if (showWeeklyMacroDistribution) {
|
||||
tasks.splice(2, 0, loadMacroWeekly())
|
||||
}
|
||||
|
||||
await Promise.all(tasks)
|
||||
}
|
||||
|
||||
|
||||
@@ -1120,7 +1120,12 @@ function NutritionSection({ insights, onRequest, loadingSlug, filterActiveSlugs
|
||||
<div style={{ fontSize: 12, fontWeight: 600, color: 'var(--text3)', marginBottom: 8, marginTop: 4 }}>
|
||||
Zeitverläufe (Energie & Protein)
|
||||
</div>
|
||||
<NutritionCharts days={chartDays} showWeeklyMacroDistribution={false} hideEnergyAvailabilityCard />
|
||||
<NutritionCharts
|
||||
days={chartDays}
|
||||
showWeeklyMacroDistribution={false}
|
||||
hideEnergyAvailabilityCard
|
||||
prefetchedChartPayloads={viz.chart_payloads}
|
||||
/>
|
||||
|
||||
<InsightBox insights={insights} slugs={filterActiveSlugs(['ernaehrung'])} onRequest={onRequest} loading={loadingSlug}/>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user