'use client'; import * as React from 'react'; import RouterLink from 'next/link'; import { usePathname } from 'next/navigation'; import Avatar from '@mui/material/Avatar'; import Box from '@mui/material/Box'; import Stack from '@mui/material/Stack'; import Typography from '@mui/material/Typography'; import type { Icon } from '@phosphor-icons/react/dist/lib/types'; import { Bell as BellIcon } from '@phosphor-icons/react/dist/ssr/Bell'; import { CreditCard as CreditCardIcon } from '@phosphor-icons/react/dist/ssr/CreditCard'; import { LockKey as LockKeyIcon } from '@phosphor-icons/react/dist/ssr/LockKey'; import { PlugsConnected as PlugsConnectedIcon } from '@phosphor-icons/react/dist/ssr/PlugsConnected'; import { UserCircle as UserCircleIcon } from '@phosphor-icons/react/dist/ssr/UserCircle'; import { UsersThree as UsersThreeIcon } from '@phosphor-icons/react/dist/ssr/UsersThree'; import type { NavItemConfig } from '@/types/nav'; import { paths } from '@/paths'; import { isNavItemActive } from '@/lib/is-nav-item-active'; // NOTE: First level elements are groups. const navItems = [ { key: 'personal', title: 'Personal', items: [ { key: 'account', title: 'Account', href: paths.dashboard.settings.account, icon: 'user-circle' }, { key: 'notifications', title: 'Notifications', href: paths.dashboard.settings.notifications, icon: 'bell' }, { key: 'security', title: 'Security', href: paths.dashboard.settings.security, icon: 'lock-key' }, ], }, { key: 'organization', title: 'Organization', items: [ { key: 'billing', title: 'Billing & plans', href: paths.dashboard.settings.billing, icon: 'credit-card' }, { key: 'team', title: 'Team', href: paths.dashboard.settings.team, icon: 'users-three' }, { key: 'integrations', title: 'Integrations', href: paths.dashboard.settings.integrations, icon: 'plugs-connected', }, ], }, ] satisfies NavItemConfig[]; const icons = { 'credit-card': CreditCardIcon, 'lock-key': LockKeyIcon, 'plugs-connected': PlugsConnectedIcon, 'user-circle': UserCircleIcon, 'users-three': UsersThreeIcon, bell: BellIcon, } as Record; export function SideNav(): React.JSX.Element { const pathname = usePathname(); return (
{navItems.map((group) => ( {group.title ? (
{group.title}
) : null} {group.items.map((item) => ( ))}
))}
AV
Sofia Rivers sofia@devias.io
); } interface NavItemProps extends NavItemConfig { pathname: string; } function NavItem({ disabled, external, href, icon, pathname, title }: NavItemProps): React.JSX.Element { const active = isNavItemActive({ disabled, external, href, pathname }); const Icon = icon ? icons[icon] : null; return ( {Icon ? ( ) : null} {title} ); }