import { useState } from 'react'; import { Link, useNavigate, useLocation } from 'react-router-dom'; import { useAuth } from '../../context/AuthContext'; export default function Header() { const [isDropdownOpen, setIsDropdownOpen] = useState(false); const navigate = useNavigate(); const location = useLocation(); const { user, logout, isAuthenticated } = useAuth(); const userInitial = user?.username ? user.username[0].toUpperCase() : "U"; const handleLogout = () => { logout(); setIsDropdownOpen(false); navigate('/login'); }; const isActive = (path) => { return location.pathname === path || (path === '/editor' && location.pathname === '/'); }; return (
Deck of Cards Logo Deck of Cards
Editor {isAuthenticated && ( Historial )}
{isAuthenticated ? (
{isDropdownOpen && ( <>
setIsDropdownOpen(false)}>

Usuario

{user?.username}

)}
) : (
Acceder
)}
); }