diff --git a/src/components/AppHeader.jsx b/src/components/AppHeader.jsx index 0ae9a64..6f9885e 100644 --- a/src/components/AppHeader.jsx +++ b/src/components/AppHeader.jsx @@ -1,9 +1,10 @@ import { useState } from 'react'; import fendiLogo from '/favicon.png' -import { AppBar, Toolbar, Typography, InputBase, IconButton, Box } from '@mui/material'; +import { AppBar, Toolbar, Typography, InputBase, IconButton, Box, Avatar} from '@mui/material'; import SearchIcon from '@mui/icons-material/Search'; import MenuDrawer from './MenuDrawer'; import MenuIcon from '@mui/icons-material/Menu'; +import { useAuth } from '../context/AuthContext'; export default function AppHeader({ zone = 'public', onSelectMenuItem }) { @@ -14,6 +15,7 @@ export default function AppHeader({ zone = 'public', onSelectMenuItem }) { }; const [menuOpen, setMenuOpen] = useState(false); + const { user, logout } = useAuth(); const isPrivate = zone === 'private'; const isRestricted = zone === 'restricted'; @@ -53,7 +55,7 @@ export default function AppHeader({ zone = 'public', onSelectMenuItem }) { )} {/* Login button only visible for public zone */} - {isPublic && ( + {isPublic && !user && ( @@ -63,6 +65,13 @@ export default function AppHeader({ zone = 'public', onSelectMenuItem }) { )} + {user && ( + + {user.name} + + + )} + {/* Rendering the Drawer */} - Iniciar sesión + Sign in with Google { - const user = jwt_decode(credentialResponse.credential); + const user = jwtDecode(credentialResponse.credential); login(user); navigate('/'); }} onError={() => { - console.log('Error al iniciar sesión'); + console.log('Error signing in'); }} />