From 6a8656da3dd4bfe90c50fda220093f0411553bb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Gerhard=20Lindesva=CC=88rd?= Date: Mon, 26 Feb 2024 16:40:09 +0100 Subject: [PATCH] ability to use custom dates everywhere --- .../dashboards/[dashboardId]/list-reports.tsx | 38 +++++++---- .../[projectId]/overview-metrics.tsx | 15 ++++- .../[projectId]/overview-sticky-header.tsx | 32 ++++++++- .../[organizationId]/[projectId]/page.tsx | 1 - .../[projectId]/profiles/[profileId]/page.tsx | 18 ++--- .../[projectId]/reports/report-editor.tsx | 28 +++++++- .../overview/overview-top-devices.tsx | 13 +++- .../overview/overview-top-events.tsx | 5 +- .../components/overview/overview-top-geo.tsx | 11 +++- .../overview/overview-top-pages.tsx | 9 ++- .../overview/overview-top-sources.tsx | 19 +++++- .../components/overview/useOverviewOptions.ts | 26 +++++++- .../web/src/components/report/ReportRange.tsx | 65 ++++++++----------- apps/web/src/components/report/reportSlice.ts | 33 +++++----- apps/web/src/components/ui/key-value.tsx | 11 +++- packages/constants/index.ts | 18 +++++ packages/constants/package.json | 1 + packages/db/clickhouse_tables.sql | 2 +- pnpm-lock.yaml | 4 +- 19 files changed, 254 insertions(+), 95 deletions(-) diff --git a/apps/web/src/app/(app)/[organizationId]/[projectId]/dashboards/[dashboardId]/list-reports.tsx b/apps/web/src/app/(app)/[organizationId]/[projectId]/dashboards/[dashboardId]/list-reports.tsx index cf25f406..2beeb2af 100644 --- a/apps/web/src/app/(app)/[organizationId]/[projectId]/dashboards/[dashboardId]/list-reports.tsx +++ b/apps/web/src/app/(app)/[organizationId]/[projectId]/dashboards/[dashboardId]/list-reports.tsx @@ -1,9 +1,8 @@ 'use client'; -import { useState } from 'react'; import { StickyBelowHeader } from '@/app/(app)/[organizationId]/[projectId]/layout-sticky-below-header'; +import { useOverviewOptions } from '@/components/overview/useOverviewOptions'; import { LazyChart } from '@/components/report/chart/LazyChart'; -import { ReportRange } from '@/components/report/ReportRange'; import { Button } from '@/components/ui/button'; import { DropdownMenu, @@ -18,9 +17,13 @@ import { ChevronRight, MoreHorizontal, PlusIcon, Trash } from 'lucide-react'; import Link from 'next/link'; import { useRouter } from 'next/navigation'; -import { getDefaultIntervalByRange } from '@mixan/constants'; +import { + getDefaultIntervalByDates, + getDefaultIntervalByRange, +} from '@mixan/constants'; import type { getReportsByDashboardId } from '@mixan/db'; -import type { IChartRange } from '@mixan/validation'; + +import { OverviewReportRange } from '../../overview-sticky-header'; interface ListReportsProps { reports: Awaited>; @@ -29,16 +32,12 @@ interface ListReportsProps { export function ListReports({ reports }: ListReportsProps) { const router = useRouter(); const params = useAppParams<{ dashboardId: string }>(); - const [range, setRange] = useState(null); + const { range, startDate, endDate } = useOverviewOptions(); return ( <> - setRange((p) => (p === value ? null : value))} - /> +