Skip to content

Commit

Permalink
fixes empty prices when there's no data for the day
Browse files Browse the repository at this point in the history
  • Loading branch information
tonymtz committed Dec 24, 2023
1 parent b14ba28 commit 589ceee
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/lib/data/report-week.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export async function getWeekReport () {
const today = new Date()
today.setHours(0, 0, 0, 0)

for (let i = 0; i < 7; i++) {
for (let i = 0; i < 8; i++) {
const endDate = new Date(today)
endDate.setDate(today.getDate() - i)

Expand Down Expand Up @@ -45,7 +45,10 @@ export async function getWeekReport () {
}
})

week[startDate.toLocaleDateString()] = prices
// If there is no price for the day, we don't want to show it
if (prices.banxico.buy !== 0) {
week[startDate.toLocaleDateString()] = prices
}
}

return week
Expand Down

0 comments on commit 589ceee

Please sign in to comment.