import type { JSX } from "react"; import { AppShellNavbar, AppShellSection, Image, ScrollArea } from "@mantine/core"; import type { TablerIcon, TablerIconProps } from "@homarr/ui"; import type { ClientNavigationLink } from "./navigation-link"; import { CommonNavLink } from "./navigation-link"; interface MainNavigationProps { headerSection?: JSX.Element; footerSection?: JSX.Element; links: NavigationLink[]; } export const MainNavigation = ({ headerSection, footerSection, links }: MainNavigationProps) => { return ( {headerSection && {headerSection}} {links.map((link, index) => { if (link.hidden) { return null; } const { icon: TablerIcon, iconProps, ...props } = link; const Icon = typeof TablerIcon === "string" ? ( ) : ( ); let clientLink: ClientNavigationLink; if ("items" in props) { clientLink = { ...props, items: props.items .filter((item) => !item.hidden) .map((item) => { return { ...item, icon: , }; }), } as ClientNavigationLink; } else { clientLink = props as ClientNavigationLink; } return ; })} {footerSection && {footerSection}} ); }; interface CommonNavigationLinkProps { label: string; icon: TablerIcon | string; iconProps?: TablerIconProps; hidden?: boolean; } interface NavigationLinkHref extends CommonNavigationLinkProps { href: string; external?: boolean; } interface NavigationLinkWithItems extends CommonNavigationLinkProps { items: NavigationLinkHref[]; } export type NavigationLink = NavigationLinkHref | NavigationLinkWithItems;