import { LogoHeader } from "./LogoHeader"; import { useNavigate } from "react-router-dom"; import Icon from "@/Icons/Icon"; import { ProfileLink } from "../../Element/User/ProfileLink"; import Avatar from "../../Element/User/Avatar"; import useLogin from "../../Hooks/useLogin"; import { useUserProfile } from "@snort/system-react"; import { NoteCreatorButton } from "../../Element/Event/Create/NoteCreatorButton"; import { FormattedMessage, useIntl } from "react-intl"; import classNames from "classnames"; import { getCurrentSubscription } from "@/Subscription"; import { HasNotificationsMarker } from "@/Pages/Layout/HasNotificationsMarker"; import NavLink from "@/Element/Button/NavLink"; const MENU_ITEMS = [ { label: "Home", icon: "home", link: "/", nonLoggedIn: true, }, { label: "Search", icon: "search", link: "/search", nonLoggedIn: true, }, { label: "Notifications", icon: "bell", link: "/notifications", }, { label: "Messages", icon: "mail", link: "/messages", }, { label: "Deck", icon: "deck", link: "/deck", }, { label: "Social Graph", icon: "graph", link: "/graph", }, { label: "About", icon: "info", link: "/donate", nonLoggedIn: true, }, { label: "Settings", icon: "settings", link: "/settings", }, ]; const getNavLinkClass = (isActive: boolean, narrow: boolean) => { const baseClasses = "rounded-full p-3 flex flex-row items-center transition-colors duration-200 hover:bg-bg-secondary hover:no-underline"; const activeClasses = "active font-bold"; return classNames(baseClasses, { [activeClasses]: isActive, "xl:px-4": !narrow, }); }; export default function NavSidebar({ narrow = false }) { const { publicKey, subscriptions, readonly } = useLogin(s => ({ publicKey: s.publicKey, subscriptions: s.subscriptions, readonly: s.readonly, })); const profile = useUserProfile(publicKey); const navigate = useNavigate(); const sub = getCurrentSubscription(subscriptions); const { formatMessage } = useIntl(); const className = classNames( { "xl:w-56 xl:gap-2 xl:items-start": !narrow }, "overflow-y-auto hide-scrollbar sticky items-center border-r border-border-color top-0 z-20 h-screen max-h-screen hidden md:flex flex-col px-2 py-4 flex-shrink-0 gap-1", ); const readOnlyIcon = readonly && ( ); const showDeck = CONFIG.showDeck || !(CONFIG.deckSubKind !== undefined && (sub?.type ?? -1) < CONFIG.deckSubKind); return (
{MENU_ITEMS.filter(a => { if ((CONFIG.hideFromNavbar ?? []).includes(a.link)) { return false; } if (a.link == "/deck" && !showDeck) { return false; } return true; }).map(item => { if (!item.nonLoggedIn && !publicKey) { return ""; } return ( getNavLinkClass(isActive, narrow)}> {item.label === "Notifications" && } {!narrow && {item.label}} ); })} {publicKey ? (
) : (
)}
{publicKey && ( <>
{!narrow && {profile?.name}}
{readonly && (
)} )}
); }