import { useIsLoggedIn, useIsUserLoading } from 'common' import Link from 'next/link' import { Fragment } from 'react' import { cn } from 'ui' import { MobileNavAccountActions } from 'ui-patterns/MobileNav/MobileNavAccountActions' import { MobileNavTabs } from 'ui-patterns/MobileNav/MobileNavTabs' import type { DropdownMenuItem } from '../Navigation.types' import { MenuItem } from './GlobalNavigationMenu' import NavigationMenu, { MenuId } from './NavigationMenu' import { isMenuLevel } from './NavigationMenu.utils' import { IA_NAV_PENDING_CLASS, useIaNavReady, useNavItems } from '@/features/IaNav' const SectionMenuItems = ({ section, activeLevel, }: { section: DropdownMenuItem[] activeLevel: string }) => section[0].menuItems?.map((menuItem, menuItemIndex) => ( {menuItem .filter((item) => item.enabled !== false) .map((item) => !item.href ? (
{item.label}
) : ( ) )}
)) // the header has one burger, so the sidebar drawer also holds the top nav groups export const GlobalMenuDrawerSection = ({ selectedLabel, currentLabel, currentLevel, onGroupPick, className, }: { selectedLabel: string | undefined currentLabel: string | undefined currentLevel: string onGroupPick: (label: string) => void className?: string }) => { const { GLOBAL_MENU_ITEMS } = useNavItems() const isNavReady = useIaNavReady() const sections = GLOBAL_MENU_ITEMS.filter((section) => section[0].enabled !== false) const selectedSection = sections.find((section) => section[0].label === selectedLabel) // a group without menu items, such as start, opens its own sidebar nav in place const selectedMenuId = Object.values(MenuId).find((id) => id === selectedSection?.[0].level) return (
({ label: section.label, href: section.menuItems || section.level ? undefined : section.href, }))} selectedLabel={selectedLabel} currentLabel={currentLabel} onTabSelect={onGroupPick} placeholder="Sections" linkAs={Link} /> {selectedSection?.[0].menuItems ? (
) : selectedMenuId ? (
{selectedLabel === currentLabel ? null : }
) : null}
) } export const GlobalMenuDrawerFooter = ({ className }: { className?: string }) => { const isLoggedIn = useIsLoggedIn() const isUserLoading = useIsUserLoading() return isUserLoading ? (
) : ( ) }