We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 32bb8c1 commit 4a6f82bCopy full SHA for 4a6f82b
components/dashboard/src/components/UsageView.tsx
@@ -46,12 +46,13 @@ function UsageView({ attributionId }: UsageViewProps) {
46
const location = useLocation();
47
useEffect(() => {
48
const match = /#(\d{4}-\d{2}-\d{2}):(\d{4}-\d{2}-\d{2})/.exec(location.hash);
49
- if (match) {
50
- try {
51
- setStartDate(dayjs(match[1], "YYYY-MM-DD"));
52
- setEndDate(dayjs(match[2], "YYYY-MM-DD"));
53
- } catch (e) {
54
- console.error(e);
+ try {
+ const today = new Date();
+ const prevMonth = new Date(today.getFullYear(), today.getMonth() - 1, today.getDate());
+ const todayStr = today.toISOString().slice(0, 10);
+ const prevMonthStr = prevMonth.toISOString().slice(0, 10);
+ setStartDate(dayjs(prevMonthStr));
55
+ setEndDate(dayjs(todayStr));
56
}
57
58
(async () => {
0 commit comments