diff --git a/frontend/src/pages/NutritionPage.jsx b/frontend/src/pages/NutritionPage.jsx index 7ab28e9..4a75ee9 100644 --- a/frontend/src/pages/NutritionPage.jsx +++ b/frontend/src/pages/NutritionPage.jsx @@ -24,6 +24,7 @@ function DataTab({ entries, onUpdate }) { const [editValues, setEditValues] = useState({}) const [saving, setSaving] = useState(false) const [error, setError] = useState(null) + const [filter, setFilter] = useState('30') // days to show (7, 30, 90, 'all') const startEdit = (e) => { setEditId(e.id) @@ -72,6 +73,14 @@ function DataTab({ entries, onUpdate }) { } } + // Filter entries by date range + const filteredEntries = filter === 'all' + ? entries + : entries.filter(e => { + const daysDiff = dayjs().diff(dayjs(e.date), 'day') + return daysDiff <= parseInt(filter) + }) + if (entries.length === 0) { return (