import { isUndefined } from 'lodash' import { ArrowUpRight, LogOut } from 'lucide-react' import Link from 'next/link' import { PropsWithChildren, ReactNode, useState } from 'react' import { Badge, cn, Menu } from 'ui' import MobileSheetNav from 'ui-patterns/MobileSheetNav/MobileSheetNav' import { LayoutHeader } from '../ProjectLayout/LayoutHeader' import type { SidebarLink, SidebarSection } from './AccountLayout.types' import { useAppStateSnapshot } from 'state/app-state' interface WithSidebarProps { title: string breadcrumbs: any[] sections: SidebarSection[] header?: ReactNode subitems?: any[] subitemsParentKey?: number hideSidebar?: boolean customSidebarContent?: ReactNode } const WithSidebar = ({ title, header, breadcrumbs = [], children, sections, subitems, subitemsParentKey, hideSidebar = false, customSidebarContent, }: PropsWithChildren) => { const noContent = !sections && !customSidebarContent const { mobileMenuOpen, setMobileMenuOpen } = useAppStateSnapshot() return (
{!hideSidebar && !noContent && ( )}
{children}
) } export default WithSidebar export const SidebarContent = ({ title, header, sections, subitems, subitemsParentKey, customSidebarContent, className, }: PropsWithChildren> & { className?: string }) => { return ( <>
{title && (

{title}

)} {header && header}
{customSidebarContent} {sections.map((section) => { return Boolean(section.heading) ? ( ) : (
) })}
) } interface SectionWithHeadersProps { section: SidebarSection subitems?: any[] subitemsParentKey?: number } const SectionWithHeaders = ({ section, subitems, subitemsParentKey }: SectionWithHeadersProps) => (
{section.heading && } {section.versionLabel && (
{section.versionLabel}
)} { }
) interface SidebarItemProps { links: SidebarLink[] subitems?: any[] subitemsParentKey?: number } const SidebarItem = ({ links, subitems, subitemsParentKey }: SidebarItemProps) => { return ( ) } interface SidebarLinkProps extends SidebarLink { id: string isSubitem?: boolean } const SidebarLinkItem = ({ id, label, href, isActive, isSubitem, isExternal, onClick, icon, }: SidebarLinkProps) => { if (isUndefined(href)) { let icon if (isExternal) { icon = } if (label === 'Log out') { icon = } return ( {})} icon={icon} > {isSubitem ?

{label}

: label}
) } return ( {isExternal && ( )}
{isSubitem ?

{label}

: label}
{icon}
) }