import { useEffect, useState } from 'react' import { api } from '../lib/api.js' export default function Trainer() { const [email, setEmail] = useState('marija.trajkovska@gmail.com') const [from, setFrom] = useState('2026-01-20') const [to, setTo] = useState('2026-02-01') const [intake, setIntake] = useState([]) const [macros, setMacros] = useState([]) const [progress, setProgress] = useState([]) const [density, setDensity] = useState([]) const [nutrient, setNutrient] = useState('Protein') const [error, setError] = useState(null) const loadClient = async () => { setError(null) try { setIntake(await api.get(`/trainer/clients/${email}/intake?from=${from}&to=${to}`)) setMacros(await api.get(`/trainer/clients/${email}/macros?from=${from}&to=${to}`)) setProgress(await api.get(`/trainer/clients/${email}/progress`)) } catch (e) { setError(e.message) } } const loadDensity = () => api.get(`/trainer/analysis/nutrient-density?nutrient=${nutrient}&limit=8`) .then(setDensity).catch(e => setError(e.message)) useEffect(() => { loadDensity() }, []) return (
{error &&
{error}
}

Client report

setEmail(e.target.value)} placeholder="client email" /> setFrom(e.target.value)} /> setTo(e.target.value)} />
{intake.length > 0 && (

Daily intake

{intake.map(d => ( ))}
daykcalmeals
{d.day} {d.kcalConsumed}{d.mealsLogged}
)} {macros.length > 0 && (

Macronutrients over the period

{macros.map(m => ( ))}
{m.nutrient}{m.total} {m.unit}
)} {progress.length > 0 && (

Biometric progress

{progress.map(p => ( ))}
dateweightchangeBMI
{p.date}{p.weight} {p.changeSincePrevious ?? '—'}{p.bmi ?? '—'}
)}

Recipe analysis

setNutrient(e.target.value)} placeholder="nutrient, e.g. Protein" />
{density.map(d => ( ))}
recipekcal/portionper portionper 100 kcal
{d.recipe}{d.kcalPerServing} {d.amountPerServing}{d.amountPer100Kcal}
) }