import React, { useEffect, useState } from "react"; import { Home, Bookmark, Settings, LogOut, Bell, Sun, Moon, Monitor, Folder, LogIn, PenSquare, MessageSquareText, Highlighter, Compass, } from "lucide-react"; import { useStore } from "@nanostores/react"; import { $user, logout } from "../../store/auth"; import { $theme, cycleTheme } from "../../store/theme"; import { getUnreadNotificationCount } from "../../api/client"; import { Link, useLocation } from "react-router-dom"; import { Avatar, CountBadge } from "../ui"; export default function Sidebar() { const user = useStore($user); const theme = useStore($theme); const location = useLocation(); const currentPath = location.pathname; const [unreadCount, setUnreadCount] = useState(0); useEffect(() => { if (!user) return; const checkNotifications = async () => { const count = await getUnreadNotificationCount(); setUnreadCount(count); }; checkNotifications(); const interval = setInterval(checkNotifications, 30000); return () => clearInterval(interval); }, [user]); const publicNavItems = [ { icon: Home, label: "Feed", href: "/home", badge: undefined }, { icon: Compass, label: "Discover", href: "/discover", badge: undefined }, { icon: MessageSquareText, label: "Annotations", href: "/annotations", badge: undefined, }, { icon: Highlighter, label: "Highlights", href: "/highlights", badge: undefined, }, { icon: Bookmark, label: "Bookmarks", href: "/bookmarks", badge: undefined, }, ]; const authNavItems = [ { icon: Home, label: "Feed", href: "/home" }, { icon: Compass, label: "Discover", href: "/discover" }, { icon: Bell, label: "Activity", href: "/notifications", badge: unreadCount, }, { icon: MessageSquareText, label: "Annotations", href: "/annotations" }, { icon: Highlighter, label: "Highlights", href: "/highlights" }, { icon: Bookmark, label: "Bookmarks", href: "/bookmarks" }, { icon: Folder, label: "Collections", href: "/collections" }, ]; const navItems = user ? authNavItems : publicNavItems; return ( ); }