import { ReactNode } from 'react'; import Link from 'next/link'; import { Sidebar, SidebarHeader, SidebarSection, SidebarItem, Button, Icon, Row, } from '@umami/react-zen'; import { Globe, LayoutDashboard, Link as LinkIcon, Logo, Grid2X2, Settings, LockKeyhole, PanelLeft, Eye, Lightning, User, Clock, Target, Funnel, Path, Magnet, Tag, Money, Network, Arrow, Sheet, } from '@/components/icons'; import { useMessages, useNavigation, useGlobalState } from '@/components/hooks'; import { LinkButton } from '@/components/common/LinkButton'; type NavLink = { id: string; label: string; path: string; icon: ReactNode; }; export function SideNav(props: any) { const { formatMessage, labels } = useMessages(); const { websiteId, pathname, renderUrl } = useNavigation(); const [isCollapsed, setCollapsed] = useGlobalState('sidenav-collapsed'); const isWebsite = websiteId && !pathname.includes('/settings'); const links = [ { id: 'websites', label: formatMessage(labels.websites), path: '/websites', icon: , }, { id: 'boards', label: formatMessage(labels.boards), path: '/boards', icon: , }, { id: 'links', label: formatMessage(labels.links), path: '/links', icon: , }, { id: 'pixels', label: formatMessage(labels.pixels), path: '/pixels', icon: , }, ]; const websiteLinks = [ { id: 'overview', label: formatMessage(labels.overview), icon: , path: '/', }, { id: 'events', label: formatMessage(labels.events), icon: , path: '/events', }, { id: 'sessions', label: formatMessage(labels.sessions), icon: , path: '/sessions', }, { id: 'realtime', label: formatMessage(labels.realtime), icon: , path: '/realtime', }, { id: 'breakdown', label: formatMessage(labels.breakdown), icon: , path: '/breakdown', }, { id: 'goals', label: formatMessage(labels.goals), icon: , path: '/goals', }, { id: 'funnel', label: formatMessage(labels.funnels), icon: , path: '/funnels', }, { id: 'journeys', label: formatMessage(labels.journeys), icon: , path: '/journeys', }, { id: 'retention', label: formatMessage(labels.retention), icon: , path: '/retention', }, { id: 'utm', label: formatMessage(labels.utm), icon: , path: '/utm', }, { id: 'revenue', label: formatMessage(labels.revenue), icon: , path: '/revenue', }, { id: 'attribution', label: formatMessage(labels.attribution), icon: , path: '/attribution', }, ]; const bottomLinks = [ { id: 'settings', label: formatMessage(labels.settings), path: '/settings', icon: , }, { id: 'admin', label: formatMessage(labels.admin), path: '/admin', icon: , }, ]; return ( } /> {!isWebsite && } {isWebsite && ( <> )} {!isWebsite && } ); } const NavItems = ({ items, prefix = '', params, }: { items: NavLink[]; prefix?: string; params?: Record | false; }) => { const { renderUrl, pathname, websiteId } = useNavigation(); return items.map(({ id, path, label, icon }) => { const isSelected = websiteId ? (path === '/' && pathname.endsWith(websiteId)) || pathname.endsWith(path) : pathname.startsWith(path); return ( ); }); };