Skip to content

Commit bf9efa4

Browse files
bonysureliyagtsiolis
authored andcommitted
Use the actual current period on the usage page
1 parent e4e0514 commit bf9efa4

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
@@ -48,9 +48,14 @@ function UsageView({ attributionId }: UsageViewProps) {
4848
const match = /#(\d{4}-\d{2}-\d{2}):(\d{4}-\d{2}-\d{2})/.exec(location.hash);
4949
if (match) {
5050
try {
51-
setStartDate(dayjs(match[1], "YYYY-MM-DD"));
52-
setEndDate(dayjs(match[2], "YYYY-MM-DD"));
51+
const today = new Date();
52+
const prevMonth = new Date(today.getFullYear(), today.getMonth() - 1, today.getDate());
53+
const todayStr = today.toISOString().slice(0, 10);
54+
const prevMonthStr = prevMonth.toISOString().slice(0, 10);
55+
setStartDate(dayjs(prevMonthStr));
56+
setEndDate(dayjs(todayStr));
5357
} catch (e) {
58+
// Catches the Error
5459
console.error(e);
5560
}
5661
}

0 commit comments

Comments
 (0)