"use client"; import Image from "next/image"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { Bell, BellDot, ListTodo, LogOut, Settings, UserPlus } from "lucide-react"; import { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupContent, SidebarHeader, SidebarMenu, SidebarMenuButton, SidebarMenuItem, SidebarSeparator, useSidebar, } from "@/components/ui/sidebar"; import Avatar from "@/components/ui/avatar"; import LanguageSwitcher from "@/components/LanguageSwitcher"; import { useTranslation, type TranslationKey } from "@/lib/i18n"; import { useNotification } from "@/lib/notification-context"; import { useUser } from "@/lib/user-context"; import { clearToken } from "@/lib/auth"; const navItems: { href: string; labelKey: TranslationKey; icon: typeof ListTodo }[] = [ { href: "/todos", labelKey: "navTodo", icon: ListTodo }, { href: "/reminders", labelKey: "navReminder", icon: Bell }, { href: "/invites", labelKey: "navInvites", icon: UserPlus }, { href: "/settings", labelKey: "navSettings", icon: Settings }, { href: "/notifications", labelKey: "navNotifications", icon: BellDot }, ]; const AppSidebar = () => { const pathname = usePathname(); const { unreadCount } = useNotification(); const { user } = useUser(); const t = useTranslation(); const { isMobile } = useSidebar(); if (isMobile) { return ( ); } return (
Notify notify
{navItems.map((item) => { const isActive = pathname?.startsWith(item.href); const isNotifications = item.href === "/notifications"; return ( {isNotifications && unreadCount > 0 && ( )} {t(item.labelKey)} {isNotifications && unreadCount > 0 && ( {unreadCount} )} ); })}
{user?.username}
); }; export default AppSidebar;