'use client'; import { Column, Grid, Row, useTheme } from '@umami/react-zen'; import { usePathname } from 'next/navigation'; import { useEffect } from 'react'; import { AttributionPage } from '@/app/(main)/websites/[websiteId]/(reports)/attribution/AttributionPage'; import { BreakdownPage } from '@/app/(main)/websites/[websiteId]/(reports)/breakdown/BreakdownPage'; import { FunnelsPage } from '@/app/(main)/websites/[websiteId]/(reports)/funnels/FunnelsPage'; import { GoalsPage } from '@/app/(main)/websites/[websiteId]/(reports)/goals/GoalsPage'; import { JourneysPage } from '@/app/(main)/websites/[websiteId]/(reports)/journeys/JourneysPage'; import { RetentionPage } from '@/app/(main)/websites/[websiteId]/(reports)/retention/RetentionPage'; import { RevenuePage } from '@/app/(main)/websites/[websiteId]/(reports)/revenue/RevenuePage'; import { UTMPage } from '@/app/(main)/websites/[websiteId]/(reports)/utm/UTMPage'; import { ComparePage } from '@/app/(main)/websites/[websiteId]/compare/ComparePage'; import { EventsPage } from '@/app/(main)/websites/[websiteId]/events/EventsPage'; import { RealtimePage } from '@/app/(main)/websites/[websiteId]/realtime/RealtimePage'; import { SessionsPage } from '@/app/(main)/websites/[websiteId]/sessions/SessionsPage'; import { WebsiteHeader } from '@/app/(main)/websites/[websiteId]/WebsiteHeader'; import { WebsitePage } from '@/app/(main)/websites/[websiteId]/WebsitePage'; import { WebsiteProvider } from '@/app/(main)/websites/WebsiteProvider'; import { PageBody } from '@/components/common/PageBody'; import { useShare } from '@/components/hooks'; import { MobileMenuButton } from '@/components/input/MobileMenuButton'; import { ShareNav } from './ShareNav'; const PAGE_COMPONENTS: Record> = { '': WebsitePage, overview: WebsitePage, events: EventsPage, sessions: SessionsPage, realtime: RealtimePage, compare: ComparePage, breakdown: BreakdownPage, goals: GoalsPage, funnels: FunnelsPage, journeys: JourneysPage, retention: RetentionPage, utm: UTMPage, revenue: RevenuePage, attribution: AttributionPage, }; export function SharePage() { const share = useShare(); const { setTheme } = useTheme(); const pathname = usePathname(); const path = pathname.split('/')[3]; const { websiteId, parameters = {} } = share; useEffect(() => { const url = new URL(window?.location?.href); const theme = url.searchParams.get('theme'); if (theme === 'light' || theme === 'dark') { setTheme(theme); } }, []); // Check if the requested path is allowed const pageKey = path || ''; const isAllowed = pageKey === '' || pageKey === 'overview' || parameters[pageKey] !== false; if (!isAllowed) { return null; } const PageComponent = PAGE_COMPONENTS[pageKey] || WebsitePage; return ( {({ close }) => { return ; }} ); }