import { Link, useLocation, useRouteContext } from "@tanstack/react-router"; import { Activity, House, Inbox, Layers3, MessagesSquare, NotebookPen, Search } from "lucide-react"; import type { ReactNode } from "react"; import { Avatar, AvatarFallback } from "#/components/ui/avatar"; import { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupContent, SidebarHeader, SidebarMenu, SidebarMenuButton, SidebarMenuItem, SidebarSeparator, } from "#/components/ui/sidebar"; import { ConnectionManagerDialog } from "#/features/connections/connection-manager-dialog"; import { useUrlState } from "#/features/navigation/use-url-state"; type WorkspaceNavigationProps = { children?: ReactNode; footer?: ReactNode; hasTemporaryDecks?: boolean; }; export function WorkspaceNavigation({ children, footer, hasTemporaryDecks, }: WorkspaceNavigationProps) { const { auth } = useRouteContext({ from: "__root__" }); const [search, updateSearch] = useUrlState(); const managingAccounts = search.accounts; const setManagingAccounts = (open: boolean) => updateSearch({ accounts: open || undefined }); const pathname = useLocation({ select: (location) => location.pathname }); const navigation = [ { title: "Home", to: "/", icon: House, active: pathname === "/" }, { title: "Vitals", to: "/vitals", icon: Activity, active: pathname === "/vitals", }, { title: "Messages", to: "/support", icon: MessagesSquare, active: pathname === "/support", }, { title: "Journal", to: "/journal", icon: NotebookPen, active: pathname === "/journal", }, { title: "Reader", to: "/inbox", icon: Inbox, active: pathname === "/inbox", }, { title: "Research", to: "/deck", icon: Search, active: pathname === "/deck", }, ] as const; return (
{navigation.map((item) => ( } className="size-10 justify-center p-0" > {item.title} ))} {children && ( <> {children} )} {footer && {footer}} setManagingAccounts(true)} > {auth.owner?.name.slice(0, 1).toUpperCase()} {managingAccounts && ( setManagingAccounts(false)} hasTemporaryDecks={hasTemporaryDecks} /> )}
); }