mirror of
https://github.com/bubblecup-12/VogelSocialMedia.git
synced 2025-07-06 15:18:48 +00:00
make logout button only be there when logged in
This commit is contained in:
parent
cc9fe432c0
commit
b64dcc05b5
1 changed files with 4 additions and 5 deletions
|
@ -14,12 +14,10 @@ import { useAuth } from "../api/Auth";
|
||||||
|
|
||||||
function Header() {
|
function Header() {
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
const iconRef = useRef<HTMLImageElement>(null);
|
|
||||||
|
|
||||||
const toggleMenu = () => {
|
const toggleMenu = () => {
|
||||||
setIsOpen(!isOpen);
|
setIsOpen(!isOpen);
|
||||||
};
|
};
|
||||||
const { logout } = useAuth();
|
const { logout, user } = useAuth();
|
||||||
const iconList = [DynamicFeedIcon, AddAPhotoIcon, PersonIcon, InfoIcon, LogoutIcon];
|
const iconList = [DynamicFeedIcon, AddAPhotoIcon, PersonIcon, InfoIcon, LogoutIcon];
|
||||||
const routerLinksList = ["/","/createpost","/profile","/about","/"]
|
const routerLinksList = ["/","/createpost","/profile","/about","/"]
|
||||||
|
|
||||||
|
@ -38,14 +36,15 @@ function Header() {
|
||||||
</ListItemButton>
|
</ListItemButton>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
))}
|
))}
|
||||||
<ListItem className="drawer-list-item-button" key={"Log Out"} disablePadding>
|
{user && <ListItem className="drawer-list-item-button" key={"Log Out"} disablePadding>
|
||||||
<ListItemButton className="drawer-list-item-button" onClick={logout}>
|
<ListItemButton className="drawer-list-item-button" onClick={logout}>
|
||||||
<ListItemIcon className="drawer-list-item">
|
<ListItemIcon className="drawer-list-item">
|
||||||
{React.createElement(iconList[4])}
|
{React.createElement(iconList[4])}
|
||||||
</ListItemIcon>
|
</ListItemIcon>
|
||||||
<ListItemText className="drawer-list-item" primary={"Log Out"}/>
|
<ListItemText className="drawer-list-item" primary={"Log Out"}/>
|
||||||
</ListItemButton>
|
</ListItemButton>
|
||||||
</ListItem>
|
</ListItem> }
|
||||||
|
|
||||||
</List>
|
</List>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue