import {Link, NavLink, useLocation} from 'react-router-dom'; import {useTranslation} from 'react-i18next'; import {Dices, Languages, LayoutDashboard, Library, LogOut, Moon, Settings, Sun} from 'lucide-react'; import {Button} from '@/components/ui/button'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu'; import {usePreferences} from '@/context/PreferencesContext.jsx'; import {cn} from '@/lib/utils'; import Logo from './Logo.jsx'; import PageContainer from './PageContainer.jsx'; import SteamAvatar from './SteamAvatar.jsx'; import useSteamProfile from '../hooks/useSteamProfile.js'; const NAV_ITEMS = [ {to: '/dashboard', labelKey: 'NAV.DASHBOARD', Icon: LayoutDashboard}, // The wishlist is a tab of the library. {to: '/library', labelKey: 'NAV.LIBRARY', Icon: Library, alsoActiveOn: ['/wishlist']}, {to: '/play-next', labelKey: 'NAV.PLAY_NEXT', Icon: Dices}, ]; const navLinkClass = (isActive) => cn( 'flex items-center gap-2 rounded-lg px-3 py-2 text-sm font-medium transition-colors', isActive ? 'bg-accent text-accent-foreground' : 'text-muted-foreground hover:bg-muted hover:text-foreground', ); export default function AppHeader({isAuthenticated, onLogout}) { const {t, i18n} = useTranslation(); const {isDarkMode, setDarkMode, setLanguage} = usePreferences(); const {pathname} = useLocation(); const steamProfile = useSteamProfile(isAuthenticated); const toggleLanguage = () => setLanguage(i18n.language === 'de' ? 'en' : 'de'); const toggleTheme = () => setDarkMode(!isDarkMode); const ThemeIcon = isDarkMode ? Sun : Moon; return (
{/* On a narrow phone the menu and buttons need the room; the logo alone stays. */} ToBePlayed {isAuthenticated && ( )}
{isAuthenticated ? ( {t('NAV.SETTINGS')} {t('NAV.LANGUAGE')}: {i18n.language.toUpperCase()} {t(isDarkMode ? 'NAV.LIGHT_MODE' : 'NAV.DARK_MODE')} {t('MAIN.LOGOUT')} ) : ( <> )}
); }