import { useState, useRef, useEffect } from 'react'; import { Link, useNavigate, useLocation } from 'react-router-dom'; import { useAuthStore } from '../../store/useAuthStore'; const GITHUB_URL = 'https://github.com/davidmonterocrespo24/velxio'; const DISCORD_URL = 'https://discord.gg/rCScB9cG'; interface AppHeaderProps {} export const AppHeader: React.FC = () => { const user = useAuthStore((s) => s.user); const logout = useAuthStore((s) => s.logout); const navigate = useNavigate(); const location = useLocation(); const [dropdownOpen, setDropdownOpen] = useState(false); const [menuOpen, setMenuOpen] = useState(false); const dropdownRef = useRef(null); useEffect(() => { const handler = (e: MouseEvent) => { if (dropdownRef.current && !dropdownRef.current.contains(e.target as Node)) { setDropdownOpen(false); } }; document.addEventListener('mousedown', handler); return () => document.removeEventListener('mousedown', handler); }, []); // Close mobile menu on route change useEffect(() => { setMenuOpen(false); }, [location.pathname]); const handleLogout = async () => { setDropdownOpen(false); await logout(); navigate('/'); }; const isActive = (path: string) => location.pathname === path ? ' header-nav-link-active' : ''; return (
{/* Brand */}
Velxio
{/* Main nav links (desktop) */}
{/* Right: auth + mobile hamburger */}
{/* Auth UI */} {user ? (
{dropdownOpen && (
setDropdownOpen(false)} style={{ display: 'block', padding: '9px 14px', color: '#ccc', textDecoration: 'none', fontSize: 13 }} > My projects
)}
) : (
Sign in Sign up
)} {/* Mobile hamburger */}
); };