import { BadgeCheck, Bell, ChevronsUpDown, CreditCard, LogOut, Moon, Sun } from 'lucide-react' import { Avatar, AvatarFallback, AvatarImage } from '@mdxui/primitives/avatar' import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from '@mdxui/primitives/dropdown-menu' import { SidebarMenu, SidebarMenuButton, SidebarMenuItem, useSidebar, } from '@mdxui/primitives/sidebar' import { useAuth } from '../context/auth-context' import { useNavigation } from '../context/navigation-context' import { useContext } from 'react' import { ThemeContext } from '../context/theme-context' import type { UserIdentity, UserMenuAction } from '../types' export interface NavUserProps { /** User identity (defaults to auth context) */ user?: UserIdentity /** Additional menu actions */ actions?: UserMenuAction[] /** Path for account settings */ accountPath?: string /** Path for billing settings */ billingPath?: string /** Whether to show theme toggle */ showThemeToggle?: boolean /** Whether to show notifications item */ showNotifications?: boolean /** Custom logout handler (defaults to auth context) */ onLogout?: () => void } /** * NavUser renders the user menu in the sidebar footer. * Shows avatar, user info, and dropdown with actions. * * @example * ```tsx * * ``` */ export function NavUser({ user: userProp, actions = [], accountPath = '/settings', billingPath = '/settings/billing', showThemeToggle = true, showNotifications = false, onLogout, }: NavUserProps) { const { identity, logout } = useAuth() const { Link } = useNavigation() const { isMobile } = useSidebar() // Use ThemeContext directly - useContext returns null if not in provider const themeContext = useContext(ThemeContext) const user = userProp ?? identity const handleLogout = () => { if (onLogout) { onLogout() } else { logout() } } // Fallback user data const displayName = user?.fullName ?? 'User' const displayEmail = user?.email ?? 'user@example.com' const avatarSrc = user?.avatar ?? '' const initials = displayName.charAt(0).toUpperCase() return ( {initials} {displayName} {displayEmail} {initials} {displayName} {displayEmail} Account Billing {showNotifications && ( Notifications )} {showThemeToggle && themeContext && ( {themeContext.resolvedTheme === 'dark' ? : } {themeContext.resolvedTheme === 'dark' ? 'Light Mode' : 'Dark Mode'} )} {actions.map((action) => ( {action.href ? ( {action.icon && } {action.label} ) : ( <> {action.icon && } {action.label} > )} ))} Log out ) }