import React, { useState } from 'react'; import { User, AppNotification } from '../types'; import { Menu, X, Bell, Search, Globe, Shield, User as UserIcon, LogOut, LayoutDashboard, ChevronDown } from 'lucide-react'; import { TRANSLATIONS, Language } from '../translations'; interface HeaderProps { currentUser: User; onLogout: () => void; onLoginSimulate: () => void; currentView: string; setCurrentView: (view: string) => void; notifications: AppNotification[]; onMarkNotificationRead: (id: string) => void; onClearNotifications: () => void; onSearch: (query: string) => void; currentLanguage: string; setLanguage: (lang: any) => void; } const LANGUAGES = [ { code: 'UZ', name: "O'zbek" }, { code: 'RU', name: "Русский" }, { code: 'EN', name: "English" } ]; export const Header: React.FC = ({ currentUser, onLogout, onLoginSimulate, currentView, setCurrentView, notifications, onMarkNotificationRead, onClearNotifications, onSearch, currentLanguage, setLanguage, }) => { const [mobileMenuOpen, setMobileMenuOpen] = useState(false); const [notifDropdownOpen, setNotifDropdownOpen] = useState(false); const [langDropdownOpen, setLangDropdownOpen] = useState(false); const [searchString, setSearchString] = useState(''); const unreadNotifs = notifications.filter((n) => !n.read); const handleSearchSubmit = (e: React.FormEvent) => { e.preventDefault(); onSearch(searchString); }; const t = TRANSLATIONS[currentLanguage as Language] || TRANSLATIONS['EN']; const navItems = [ { id: 'home', label: t.navHome }, { id: 'register', label: t.navRegister }, { id: 'games', label: t.navGames }, { id: 'pro-league', label: t.navProLeague }, { id: 'results', label: t.navResults }, { id: 'profile', label: t.navProfile }, ]; return (
{/* Logo */}
{ setCurrentView('home'); setMobileMenuOpen(false); }}>
NE
NOVAESPORTS {t.webPlatform}
{/* Desktop Navigation Links */} {/* Right Header Toolbar (Search, Notifications, Lang, Auth) */}
{/* Search Input Bar */}
{ setSearchString(e.target.value); onSearch(e.target.value); }} className="w-40 xl:w-52 bg-white/5 hover:bg-white/10 focus:bg-white/10 border border-white/10 hover:border-white/20 focus:border-cyan-400 rounded-lg pl-3 pr-8 py-1.5 text-xs text-white outline-none focus:ring-1 focus:ring-cyan-500/30 transition-all font-sans" />
{/* Notification Trigger Dropdown */}
{/* Notification Box */} {notifDropdownOpen && (
{t.telemetryTitle} {notifications.length > 0 && ( )}
{notifications.length === 0 ? (
{t.noNotifs}
) : ( notifications.map((notif) => (
onMarkNotificationRead(notif.id)} className={`p-3 text-left transition-colors cursor-pointer hover:bg-white/5 ${ !notif.read ? 'bg-cyan-400/10 border-l-2 border-cyan-400' : '' }`} >
{notif.title} {notif.time}

{notif.message}

)) )}
)}
{/* Language Selector Dropdown */}
{langDropdownOpen && (
{LANGUAGES.map((lang) => ( ))}
)}
{/* User Profile Avatar / Action Button */} {currentUser ? (
setCurrentView('profile')} className="flex items-center gap-2.5 pl-2.5 border-l border-white/15 py-1 hover:opacity-90 cursor-pointer" >
{currentUser.username} {currentUser.points} {t.playPoints}
{currentUser.avatar && (currentUser.avatar.startsWith('http://') || currentUser.avatar.startsWith('https://')) ? ( avatar ) : ( {currentUser.avatar || '👤'} )}
) : ( )}
{/* Mobile menu trigger */}
{/* Quick Notify Bell for Mobile */}
{/* Mobile Drawer Navigation overlay */} {mobileMenuOpen && (
{ setSearchString(e.target.value); onSearch(e.target.value); }} className="w-full bg-white/5 border border-white/10 rounded-lg pl-3 pr-8 py-2 text-xs text-white outline-none focus:border-cyan-400" />
{navItems.map((item) => ( ))} {currentUser && currentUser.id !== 'guest' && ( )}
{currentUser ? (
{currentUser.avatar && (currentUser.avatar.startsWith('http://') || currentUser.avatar.startsWith('https://')) ? ( avatar ) : ( {currentUser.avatar || '👤'} )}
{currentUser.username} {currentUser.points} {t.playPoints}
) : ( )}
{currentUser && ( )}
)}
); };