feat: show used connected
This commit is contained in:
		| @@ -1,9 +1,10 @@ | |||||||
| import { useState } from 'react'; | import { useState } from 'react'; | ||||||
| import fendiLogo from '/favicon.png' | 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 SearchIcon from '@mui/icons-material/Search'; | ||||||
| import MenuDrawer from './MenuDrawer'; | import MenuDrawer from './MenuDrawer'; | ||||||
| import MenuIcon from '@mui/icons-material/Menu'; | import MenuIcon from '@mui/icons-material/Menu'; | ||||||
|  | import { useAuth } from '../context/AuthContext'; | ||||||
|  |  | ||||||
| export default function AppHeader({ zone = 'public', onSelectMenuItem }) { | export default function AppHeader({ zone = 'public', onSelectMenuItem }) { | ||||||
|  |  | ||||||
| @@ -14,6 +15,7 @@ export default function AppHeader({ zone = 'public', onSelectMenuItem }) { | |||||||
|   }; |   }; | ||||||
|  |  | ||||||
|   const [menuOpen, setMenuOpen] = useState(false); |   const [menuOpen, setMenuOpen] = useState(false); | ||||||
|  |   const { user, logout } = useAuth(); | ||||||
|  |  | ||||||
|   const isPrivate = zone === 'private'; |   const isPrivate = zone === 'private'; | ||||||
|   const isRestricted = zone === 'restricted'; |   const isRestricted = zone === 'restricted'; | ||||||
| @@ -53,7 +55,7 @@ export default function AppHeader({ zone = 'public', onSelectMenuItem }) { | |||||||
|         )} |         )} | ||||||
|  |  | ||||||
|         {/* Login button only visible for public zone */} |         {/* Login button only visible for public zone */} | ||||||
|         {isPublic && ( |         {isPublic && !user && ( | ||||||
|           <Box> |           <Box> | ||||||
|             <IconButton color="inherit"> |             <IconButton color="inherit"> | ||||||
|               <Typography variant="button" color="#A68A72FF"> |               <Typography variant="button" color="#A68A72FF"> | ||||||
| @@ -63,6 +65,13 @@ export default function AppHeader({ zone = 'public', onSelectMenuItem }) { | |||||||
|           </Box> |           </Box> | ||||||
|         )} |         )} | ||||||
|  |  | ||||||
|  |         {user && ( | ||||||
|  |           <Box display="flex" alignItems="center" gap={2}> | ||||||
|  |             <Typography variant="body1">{user.name}</Typography> | ||||||
|  |             <Avatar alt={user.name} src={user.picture} /> | ||||||
|  |           </Box> | ||||||
|  |         )} | ||||||
|  |  | ||||||
|         {/* Rendering the Drawer */} |         {/* Rendering the Drawer */} | ||||||
|         <MenuDrawer |         <MenuDrawer | ||||||
|           zone="private" |           zone="private" | ||||||
|   | |||||||
| @@ -11,17 +11,17 @@ export default function LoginPage() { | |||||||
|     return ( |     return ( | ||||||
|         <Box display="flex" flexDirection="column" alignItems="center" mt={10}> |         <Box display="flex" flexDirection="column" alignItems="center" mt={10}> | ||||||
|             <Typography variant="h4" gutterBottom> |             <Typography variant="h4" gutterBottom> | ||||||
|                 Iniciar sesión |                 Sign in with Google | ||||||
|             </Typography> |             </Typography> | ||||||
|  |  | ||||||
|             <GoogleLogin |             <GoogleLogin | ||||||
|                 onSuccess={(credentialResponse) => { |                 onSuccess={(credentialResponse) => { | ||||||
|                     const user = jwt_decode(credentialResponse.credential); |                     const user = jwtDecode(credentialResponse.credential); | ||||||
|                     login(user); |                     login(user); | ||||||
|                     navigate('/'); |                     navigate('/'); | ||||||
|                 }} |                 }} | ||||||
|                 onError={() => { |                 onError={() => { | ||||||
|                     console.log('Error al iniciar sesión'); |                     console.log('Error signing in'); | ||||||
|                 }} |                 }} | ||||||
|             /> |             /> | ||||||
|         </Box> |         </Box> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Rodolfo Ruiz
					Rodolfo Ruiz