import { Tooltip } from "@mui/joy"; import { EarthIcon, LibraryIcon, PaperclipIcon, UserCircleIcon } from "lucide-react"; import { observer } from "mobx-react-lite"; import { useEffect } from "react"; import { NavLink } from "react-router-dom"; import useCurrentUser from "@/hooks/useCurrentUser"; import { Routes } from "@/router"; import { userStore } from "@/store/v2"; import { cn } from "@/utils"; import { useTranslate } from "@/utils/i18n"; import BrandBanner from "./BrandBanner"; import UserBanner from "./UserBanner"; interface NavLinkItem { id: string; path: string; title: string; icon: React.ReactNode; } interface Props { collapsed?: boolean; className?: string; } const Navigation = observer((props: Props) => { const { collapsed, className } = props; const t = useTranslate(); const currentUser = useCurrentUser(); useEffect(() => { if (!currentUser) { return; } userStore.fetchInboxes(); }, []); const homeNavLink: NavLinkItem = { id: "header-memos", path: Routes.ROOT, title: t("common.memos"), icon: , }; const exploreNavLink: NavLinkItem = { id: "header-explore", path: Routes.EXPLORE, title: t("common.explore"), icon: , }; const attachmentsNavLink: NavLinkItem = { id: "header-attachments", path: Routes.ATTACHMENTS, title: t("common.attachments"), icon: , }; const signInNavLink: NavLinkItem = { id: "header-auth", path: Routes.AUTH, title: t("common.sign-in"), icon: , }; const navLinks: NavLinkItem[] = currentUser ? [homeNavLink, exploreNavLink, attachmentsNavLink] : [exploreNavLink, signInNavLink]; return (
{navLinks.map((navLink) => ( cn( "px-2 py-2 rounded-2xl border flex flex-row items-center text-lg text-gray-800 dark:text-gray-400 hover:bg-white hover:border-zinc-200 dark:hover:border-zinc-700 dark:hover:bg-zinc-800", collapsed ? "" : "w-full px-4", isActive ? "bg-white drop-shadow-sm dark:bg-zinc-900 border-zinc-200 dark:border-zinc-700" : "border-transparent", ) } key={navLink.id} to={navLink.path} id={navLink.id} viewTransition > {props.collapsed ? (
{navLink.icon}
) : ( navLink.icon )} {!props.collapsed && {navLink.title}}
))}
{currentUser && }
); }); export default Navigation;