🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
Refactor date handling in Chart and PreviousChart components
Bill Yang7202418963f6
diff --git a/client/src/app/[site]/main/components/MainSection/Chart.tsx b/client/src/app/[site]/main/components/MainSection/Chart.tsxindex b5e960803..0b33f72a4 100644--- a/client/src/app/[site]/main/components/MainSection/Chart.tsx+++ b/client/src/app/[site]/main/components/MainSection/Chart.tsx@@ -47,7 +47,12 @@ const getMax = (time: Time, bucket: TimeBucket) => {});return now < dayDate ? dayDate.toJSDate() : undefined;} else if (time.mode === "range") {- if (bucket === "day") {+ if (+ bucket === "day" ||+ bucket === "week" ||+ bucket === "month" ||+ bucket === "year"+ ) {return undefined;}const rangeDate = DateTime.fromISO(time.endDate)@@ -113,10 +118,6 @@ const getMin = (time: Time, bucket: TimeBucket) => {} else if (time.mode === "year") {const yearDate = DateTime.fromISO(time.year).startOf("year");return yearDate.toJSDate();- } else if (time.mode === "range") {- const startDate = DateTime.fromISO(time.startDate).startOf("day");- const endDate = DateTime.fromISO(time.endDate).startOf("day");- return startDate.toJSDate();}return undefined;};diff --git a/client/src/app/[site]/main/components/MainSection/PreviousChart.tsx b/client/src/app/[site]/main/components/MainSection/PreviousChart.tsxindex 91da2d32c..f40a81b90 100644--- a/client/src/app/[site]/main/components/MainSection/PreviousChart.tsx+++ b/client/src/app/[site]/main/components/MainSection/PreviousChart.tsx@@ -30,10 +30,6 @@ const getMin = (time: Time, bucket: TimeBucket) => {} else if (time.mode === "year") {const yearDate = DateTime.fromISO(time.year).startOf("year");return yearDate.toJSDate();- } else if (time.mode === "range") {- const startDate = DateTime.fromISO(time.startDate).startOf("day");- const endDate = DateTime.fromISO(time.endDate).startOf("day");- return startDate.toJSDate();}return undefined;};