Skip to content

Commit ef8b120

Browse files
bonysureliyagtsiolis
authored andcommitted
Use the actual current period on the usage page
1 parent 5beb606 commit ef8b120

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

components/dashboard/src/components/UsageView.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,14 @@ function UsageView({ attributionId }: UsageViewProps) {
4141
const match = /#(\d{4}-\d{2}-\d{2}):(\d{4}-\d{2}-\d{2})/.exec(location.hash);
4242
if (match) {
4343
try {
44-
setStartDate(dayjs(match[1], "YYYY-MM-DD"));
45-
setEndDate(dayjs(match[2], "YYYY-MM-DD"));
44+
const today = new Date();
45+
const prevMonth = new Date(today.getFullYear(), today.getMonth() - 1, today.getDate());
46+
const todayStr = today.toISOString().slice(0, 10);
47+
const prevMonthStr = prevMonth.toISOString().slice(0, 10);
48+
setStartDate(dayjs(prevMonthStr));
49+
setEndDate(dayjs(todayStr));
4650
} catch (e) {
51+
// Catches the Error
4752
console.error(e);
4853
}
4954
}

0 commit comments

Comments
 (0)