🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
add well known times
Bill Yangee6088fc910c
diff --git a/client/src/app/[site]/components/Header/DateSelector.tsx b/client/src/app/[site]/components/Header/DateSelector.tsxindex 9ac9292f6..2f5332163 100644--- a/client/src/app/[site]/components/Header/DateSelector.tsx+++ b/client/src/app/[site]/components/Header/DateSelector.tsx@@ -13,6 +13,9 @@ import { CustomDateRangePicker } from "./CustomDateRangePicker";const getLabel = (time: Time) => {if (time.mode === "range") {+ if (time.wellKnown) {+ return `${time.wellKnown}`;+ }return `${time.startDate} - ${time.endDate}`;}@@ -25,6 +28,38 @@ const getLabel = (time: Time) => {}return time.day;}+ if (time.mode === "week") {+ if (time.week === DateTime.now().startOf("week").toISODate()) {+ return "This Week";+ }+ if (+ time.week ===+ DateTime.now().minus({ weeks: 1 }).startOf("week").toISODate()+ ) {+ return "Last Week";+ }+ return `${time.week} - ${DateTime.fromISO(time.week)+ .endOf("week")+ .toISODate()}`;+ }+ if (time.mode === "month") {+ if (time.month === DateTime.now().startOf("month").toISODate()) {+ return "This Month";+ }+ if (+ time.month ===+ DateTime.now().minus({ months: 1 }).startOf("month").toISODate()+ ) {+ return "Last Month";+ }+ return time.month;+ }+ if (time.mode === "year") {+ if (time.year === DateTime.now().startOf("year").toISODate()) {+ return "This Year";+ }+ return time.year;+ }};export function DateSelector() {@@ -50,6 +85,7 @@ export function DateSelector() {mode: "range",startDate: DateTime.now().minus({ days: 2 }).toISODate(),endDate: DateTime.now().toISODate(),+ wellKnown: "Last 3 days",})}>@@ -61,6 +97,7 @@ export function DateSelector() {mode: "range",startDate: DateTime.now().minus({ days: 6 }).toISODate(),endDate: DateTime.now().toISODate(),+ wellKnown: "Last 7 days",})}>@@ -72,6 +109,7 @@ export function DateSelector() {mode: "range",startDate: DateTime.now().minus({ days: 13 }).toISODate(),endDate: DateTime.now().toISODate(),+ wellKnown: "Last 14 days",})}>@@ -83,6 +121,7 @@ export function DateSelector() {mode: "range",startDate: DateTime.now().minus({ days: 29 }).toISODate(),endDate: DateTime.now().toISODate(),+ wellKnown: "Last 30 days",})}>@@ -94,6 +133,7 @@ export function DateSelector() {mode: "range",startDate: DateTime.now().minus({ days: 59 }).toISODate(),endDate: DateTime.now().toISODate(),+ wellKnown: "Last 60 days",})}>diff --git a/client/src/app/[site]/components/MainSection/Chart.tsx b/client/src/app/[site]/components/MainSection/Chart.tsxindex e864280a7..7385bb8fc 100644--- a/client/src/app/[site]/components/MainSection/Chart.tsx+++ b/client/src/app/[site]/components/MainSection/Chart.tsx@@ -87,8 +87,6 @@ export function Chart({: undefined,}));- console.info(getMax(time, bucket));-return (<ResponsiveLinedata={[diff --git a/client/src/lib/store.ts b/client/src/lib/store.tsindex 38c0d4bab..c42b0f1e6 100644--- a/client/src/lib/store.ts+++ b/client/src/lib/store.ts@@ -10,6 +10,12 @@ type DateRangeMode = {mode: "range";startDate: string;endDate: string;+ wellKnown?:+ | "Last 3 days"+ | "Last 7 days"+ | "Last 14 days"+ | "Last 30 days"+ | "Last 60 days";};type WeekMode = {