Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Brendan Birdsong committed Sep 27, 2023
1 parent a8dc4ef commit 8b29dd5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/components/ChartModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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 (
<>
<Button sx={{marginTop: 2, marginLeft: 2}} color="primary" variant="contained" size="small" onClick={() => setShow(!show)}>{show ? 'Hide' : 'Show'} Charts</Button>
Expand Down

0 comments on commit 8b29dd5

Please sign in to comment.