chore: fix header and add icons
This commit is contained in:
parent
e4c8ed534d
commit
0d329784c5
BIN
public/alert.png
Normal file
BIN
public/alert.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 539 B |
BIN
public/refresh.png
Normal file
BIN
public/refresh.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 553 B |
@ -8,12 +8,13 @@ import { useNavigate } from 'react-router-dom';
|
|||||||
export default function AppHeader({ zone = 'public', onSelectMenuItem }) {
|
export default function AppHeader({ zone = 'public', onSelectMenuItem }) {
|
||||||
|
|
||||||
const bgColor = {
|
const bgColor = {
|
||||||
public: '#40120EFF',
|
public: 'white',
|
||||||
restricted: '#40120EFF',
|
restricted: 'white',
|
||||||
private: '#40120EFF',
|
private: 'white',
|
||||||
};
|
};
|
||||||
|
|
||||||
const [drawerExpanded, setDrawerExpanded] = useState(true);
|
const [drawerExpanded, setDrawerExpanded] = useState(true);
|
||||||
|
const [currentPage, setCurrentPage] = useState('Dashboard'); // track current page
|
||||||
const { user, logout } = useAuth();
|
const { user, logout } = useAuth();
|
||||||
|
|
||||||
const isPrivate = zone === 'private';
|
const isPrivate = zone === 'private';
|
||||||
@ -22,6 +23,13 @@ export default function AppHeader({ zone = 'public', onSelectMenuItem }) {
|
|||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
const handleMenuSelect = (page) => {
|
||||||
|
setCurrentPage(page); // update page title
|
||||||
|
onSelectMenuItem?.(page); // still notify parent
|
||||||
|
// you can also navigate if you have routes:
|
||||||
|
// navigate(`/${page.toLowerCase().replace(/\s+/g, '-')}`);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppBar position="static"
|
<AppBar position="static"
|
||||||
sx={{
|
sx={{
|
||||||
@ -32,30 +40,29 @@ export default function AppHeader({ zone = 'public', onSelectMenuItem }) {
|
|||||||
}} >
|
}} >
|
||||||
<Toolbar sx={{ justifyContent: 'space-between', flexWrap: 'wrap' }}>
|
<Toolbar sx={{ justifyContent: 'space-between', flexWrap: 'wrap' }}>
|
||||||
|
|
||||||
{/* Login button only visible for public zone */}
|
{/* LEFT SIDE: Current Page */}
|
||||||
{isPublic && !user && (
|
<Typography
|
||||||
<Box>
|
variant="h6"
|
||||||
<IconButton color="inherit" onClick={() => navigate('/login')}>
|
noWrap
|
||||||
<Typography variant="button" color="#A68A72FF">
|
sx={{ color: '#40120EFF', fontWeight: 600 }}
|
||||||
Login
|
>
|
||||||
</Typography>
|
{currentPage}
|
||||||
</IconButton>
|
</Typography>
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
|
|
||||||
|
{/* RIGHT SIDE: User Info */}
|
||||||
{user && (
|
{user && (
|
||||||
<Box display="flex" alignItems="center" gap={2}>
|
<Box display="flex" alignItems="center" gap={1}>
|
||||||
<Typography variant="body1">{user.name}</Typography>
|
|
||||||
<Avatar alt={user.name} src={user.picture} />
|
<Avatar alt={user.name} src={user.picture} />
|
||||||
|
<Typography variant="body1" color='#40120EFF'>{user.name}</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Rendering the Drawer */}
|
{/* Drawer (hidden off canvas, just keeps logic) */}
|
||||||
<MenuDrawer
|
<MenuDrawer
|
||||||
zone="private"
|
zone="private"
|
||||||
open={drawerExpanded}
|
open={drawerExpanded}
|
||||||
onClose={() => setDrawerExpanded(false)}
|
onClose={() => setDrawerExpanded(false)}
|
||||||
onSelect={onSelectMenuItem} // pass handler from App
|
onSelect={handleMenuSelect} // patched
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</Toolbar>
|
</Toolbar>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user