Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Refactor Calendar component to simplify date handling and improve layout

Bill Yangaa832a3e8133
diff --git a/client/src/app/[site]/user/[userId]/components/Calendar.tsx b/client/src/app/[site]/user/[userId]/components/Calendar.tsx
index f58bf8cc7..96d850660 100644
--- a/client/src/app/[site]/user/[userId]/components/Calendar.tsx
+++ b/client/src/app/[site]/user/[userId]/components/Calendar.tsx
@@ -1,4 +1,3 @@
-import { getTimezone } from "@/lib/store";
import { ResponsiveTimeRange } from "@nivo/calendar";
import _ from "lodash";
import { DateTime } from "luxon";
@@ -12,22 +11,22 @@ export const VisitCalendar = ({ sessionCount }: { sessionCount: UserSessionCount
const t = useExtracted();
const { resolvedTheme } = useTheme();
const nivoTheme = useNivoTheme();
+
const data = sessionCount
.map(e => ({
value: e.sessions,
- day: DateTime.fromSQL(e.date ?? 0, { zone: "utc" })
- .setZone(getTimezone())
- .toFormat("y-LL-dd"),
+ day: DateTime.fromSQL(e.date ?? 0).toFormat("y-LL-dd"),
}))
.reverse();
+
const maxValue = _.get(_.sortBy(data, "value")[Math.floor(data.length * 0.95)], "value");
if (data.length === 0) {
return null;
}
- const toDate = DateTime.now().toFormat("y-LL-dd");
+ const toDate = DateTime.now().plus({ days: 1 }).toFormat("y-LL-dd");
const fromDate = DateTime.now().minus({ days: 120 }).toFormat("y-LL-dd");
return (