From 8b29dd5bac344bd6af33b7b55e2f85e8b5eebc1f Mon Sep 17 00:00:00 2001 From: Brendan Birdsong Date: Wed, 27 Sep 2023 11:00:42 -0500 Subject: [PATCH] bug fixes --- app/components/ChartModal.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/components/ChartModal.js b/app/components/ChartModal.js index ebfbc7c..2e10f55 100644 --- a/app/components/ChartModal.js +++ b/app/components/ChartModal.js @@ -11,10 +11,12 @@ export default function ChartModal({ user }) { const [days, setDays] = useState(30); const data = []; + var entries = []; + var lastEntry = {}; if (days) { const lastDayEntries = user.entries.slice(0, days); - const entries = sortEntries(lastDayEntries, true); + entries = sortEntries(lastDayEntries, true); for (var i = 1; i < entries.length; i++) { const curEntry = entries[i - 1]; const nextEntry = entries[i]; @@ -38,14 +40,14 @@ export default function ChartModal({ user }) { caloricVariance: ((nextWeekCalories - curWeekCalories)), }); } + + lastEntry = entries[0]; } if (user.entries.length <= 1) { return; } - var lastEntry = entries[0]; - return ( <>