'use client' import { useState } from 'react' import Link from 'next/link' import { usePathname, useSearchParams } from 'next/navigation' import { cn } from '@/lib/utils' import { StickyNote, Bell, Archive, Trash2, Tag, ChevronDown, ChevronUp, Settings, User, Shield, Coffee, LogOut } from 'lucide-react' import { useLabels } from '@/context/LabelContext' import { LabelManagementDialog } from './label-management-dialog' import { useSession, signOut } from 'next-auth/react' import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar' import { useRouter } from 'next/navigation' import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu' import { Button } from '@/components/ui/button' import { LABEL_COLORS } from '@/lib/types' export function Sidebar({ className, user }: { className?: string, user?: any }) { const pathname = usePathname() const searchParams = useSearchParams() const router = useRouter() const { labels, getLabelColor } = useLabels() const [isLabelsExpanded, setIsLabelsExpanded] = useState(false) const { data: session } = useSession() const currentUser = user || session?.user const currentLabels = searchParams.get('labels')?.split(',').filter(Boolean) || [] const currentSearch = searchParams.get('search') // Show first 5 labels by default, or all if expanded const displayedLabels = isLabelsExpanded ? labels : labels.slice(0, 5) const hasMoreLabels = labels.length > 5 const userRole = (currentUser as any)?.role || 'USER' const userInitials = currentUser?.name ? currentUser.name.split(' ').map((n: string) => n[0]).join('').toUpperCase().substring(0, 2) : 'U' const NavItem = ({ href, icon: Icon, label, active, onClick, iconColorClass }: any) => ( {label} ) return ( ) }