import * as React from 'react'; import { Link, useNavigate } from 'react-router-dom'; import IsAuthenticated from '../authentication/IsAuthenticated'; import axiosapi from '../../api/axiosapi'; import AppBar from '@mui/material/AppBar'; import Box from '@mui/material/Box'; import Toolbar from '@mui/material/Toolbar'; import IconButton from '@mui/material/IconButton'; import Typography from '@mui/material/Typography'; import Menu from '@mui/material/Menu'; import MenuIcon from '@mui/icons-material/Menu'; import Container from '@mui/material/Container'; import Avatar from '@mui/material/Avatar'; import Button from '@mui/material/Button'; import Tooltip from '@mui/material/Tooltip'; import MenuItem from '@mui/material/MenuItem'; import AdbIcon from '@mui/icons-material/Adb'; import Stack from '@mui/material/Stack'; const pages = { TestAuth: '/testAuth', }; const settings = { Profile: '/profile', Account: '/account', Dashboard: '/dashboard', }; function NavBar() { const Navigate = useNavigate(); const [anchorElNav, setAnchorElNav] = React.useState(null); const [anchorElUser, setAnchorElUser] = React.useState(null); const handleOpenNavMenu = (event) => { setAnchorElNav(event.currentTarget); }; const handleOpenUserMenu = (event) => { setAnchorElUser(event.currentTarget); }; const handleCloseNavMenu = () => { setAnchorElNav(null); }; const handleCloseUserMenu = () => { setAnchorElUser(null); }; const isAuthenticated = IsAuthenticated(); const logout = () => { // Log out the user, clear tokens, and navigate to the "/testAuth" route axiosapi.apiUserLogout(); Navigate('/'); } return ( LOGO {Object.entries(pages).map(([page, path]) => ( {page} ))} LOGO {Object.entries(pages).map(([page, path]) => ( ))} {isAuthenticated ? ( {Object.entries(settings).map(([setting, path]) => ( {setting} ))} Logout ) : ( )} ); } export default NavBar;