feat: implement energy availability warning and enhance nutrition visualization
Deploy Development / deploy (push) Successful in 55s
Build Test / pytest-backend (push) Successful in 9s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 16s

- Added `get_energy_availability_warning_payload` function to assess energy availability and provide contextual warnings based on multiple health indicators.
- Integrated energy availability KPI tile into the nutrition history visualization, enhancing user insights on energy balance.
- Updated frontend components to conditionally display the energy availability warning, improving user experience and data interpretation.
- Refactored existing logic in `charts.py` to utilize the new energy availability functionality, streamlining data handling.
This commit is contained in:
Lars committed 2026-04-19 17:43:29 +02:00
1 parent fc816da335
commit d7304c1a44
8 files changed
+182 -102

No files matched your search

+10 -7
View File
@@ -125,14 +125,17 @@ export default function KpiTilesOverview({
<div
className="kpi-tiles-card__hint"
style={{
marginTop: 10,
padding: '8px 10px',
borderRadius: 8,
fontSize: 10,
lineHeight: 1.45,
marginTop: 6,
paddingLeft: 8,
borderLeft: `2px solid ${accent}`,
fontSize: 9,
lineHeight: 1.35,
color: 'var(--text2)',
background: 'var(--surface2)',
borderLeft: `3px solid ${accent}`,
display: '-webkit-box',
WebkitLineClamp: 2,
WebkitBoxOrient: 'vertical',
overflow: 'hidden',
wordBreak: 'break-word',
}}
>
{cardHint}
+11 -4
View File
@@ -206,7 +206,12 @@ export function WeeklyMacroDistributionPanel({ macroWeeklyData, loading, error }
/**
* Nutrition Charts (E1–E5). Verlauf: `showWeeklyMacroDistribution={false}` wenn E3 separat (z. B. neben Donut) gerendert wird.
*/
export default function NutritionCharts({ days = 28, showWeeklyMacroDistribution = true }) {
export default function NutritionCharts({
days = 28,
showWeeklyMacroDistribution = true,
/** Verlauf: E5-Kachel liegt in nutrition-history-viz KPIs — doppelte Karte ausblenden */
hideEnergyAvailabilityCard = false,
}) {
const [energyData, setEnergyData] = useState(null)
const [proteinData, setProteinData] = useState(null)
const [macroWeeklyData, setMacroWeeklyData] = useState(null)
@@ -221,15 +226,17 @@ export default function NutritionCharts({ days = 28, showWeeklyMacroDistribution
useEffect(() => {
loadCharts()
}, [days, showWeeklyMacroDistribution])
}, [days, showWeeklyMacroDistribution, hideEnergyAvailabilityCard])
const loadCharts = async () => {
const tasks = [
loadEnergyBalance(),
loadProteinAdequacy(),
loadAdherence(),
loadWarning(),
]
if (!hideEnergyAvailabilityCard) {
tasks.push(loadWarning())
}
if (showWeeklyMacroDistribution) {
tasks.splice(2, 0, loadMacroWeekly())
}
@@ -474,7 +481,7 @@ export default function NutritionCharts({ days = 28, showWeeklyMacroDistribution
)}
{!loading.adherence && !errors.adherence && renderAdherence()}
{!loading.warning && !errors.warning && renderWarning()}
{!hideEnergyAvailabilityCard && !loading.warning && !errors.warning && renderWarning()}
</div>
)
}