import { useState } from 'react'; import { Link, useNavigate, useLocation } from 'react-router-dom'; import { useAuth } from '../../context/AuthContext'; export default function MainLayout({ children }) { 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 (
Usuario
{user?.username}