|
| 1 | +import { createFileRoute, redirect } from '@tanstack/react-router'; |
| 2 | +import { useTranslation } from '@i18next-toolkit/react'; |
| 3 | +import { CommonWrapper } from '@/components/CommonWrapper'; |
| 4 | +import { routeAuthBeforeLoad } from '@/utils/route'; |
| 5 | +import { CommonHeader } from '@/components/CommonHeader'; |
| 6 | +import { ScrollArea } from '@/components/ui/scroll-area'; |
| 7 | +import { Layout } from '@/components/layout'; |
| 8 | +import { |
| 9 | + ResizableHandle, |
| 10 | + ResizablePanel, |
| 11 | + ResizablePanelGroup, |
| 12 | +} from '@/components/ui/resizable'; |
| 13 | +import { cn } from '@/utils/style'; |
| 14 | +import { MetricsSection } from '@/components/insights/MetricsSection'; |
| 15 | +import { isDev } from '@/utils/env'; |
| 16 | + |
| 17 | +export const Route = createFileRoute('/insights')({ |
| 18 | + beforeLoad: (opts) => { |
| 19 | + if (!isDev) { |
| 20 | + throw redirect({ |
| 21 | + to: '/', |
| 22 | + }); |
| 23 | + } |
| 24 | + |
| 25 | + return routeAuthBeforeLoad?.(opts); |
| 26 | + }, |
| 27 | + component: PageComponent, |
| 28 | +}); |
| 29 | + |
| 30 | +function PageComponent() { |
| 31 | + const { t } = useTranslation(); |
| 32 | + |
| 33 | + return ( |
| 34 | + <Layout> |
| 35 | + <CommonWrapper header={<CommonHeader title={t('Insights')} />}> |
| 36 | + <ResizablePanelGroup |
| 37 | + className="flex-1 items-stretch" |
| 38 | + direction="horizontal" |
| 39 | + > |
| 40 | + <ResizablePanel collapsedSize={1} className={cn('flex flex-col')}> |
| 41 | + <ScrollArea className="h-full overflow-hidden p-4"> |
| 42 | + <div>foooooooooo</div> |
| 43 | + </ScrollArea> |
| 44 | + </ResizablePanel> |
| 45 | + |
| 46 | + <ResizableHandle withHandle /> |
| 47 | + |
| 48 | + <ResizablePanel defaultSize={30}> |
| 49 | + <ScrollArea className="h-full overflow-hidden p-4"> |
| 50 | + <div className="flex flex-col space-y-8"> |
| 51 | + <MetricsSection title="Metrics" /> |
| 52 | + <MetricsSection title="Filters" /> |
| 53 | + <MetricsSection title="Breakdown" /> |
| 54 | + </div> |
| 55 | + </ScrollArea> |
| 56 | + </ResizablePanel> |
| 57 | + </ResizablePanelGroup> |
| 58 | + </CommonWrapper> |
| 59 | + </Layout> |
| 60 | + ); |
| 61 | +} |
0 commit comments