|
|
|
@ -4,39 +4,28 @@ import { Toolbar, Typography, Button, IconButton, Link } from "@material-ui/core
|
|
|
|
import AccountCircle from '@mui/icons-material/AccountCircle';
|
|
|
|
import AccountCircle from '@mui/icons-material/AccountCircle';
|
|
|
|
import logo from "../assets/BudgetBuddyLogo.png"
|
|
|
|
import logo from "../assets/BudgetBuddyLogo.png"
|
|
|
|
import "./NavBar.css"
|
|
|
|
import "./NavBar.css"
|
|
|
|
import checkLogin from "../utils/utils";
|
|
|
|
import {checkLogin, getFirstName} from "../utils/utils";
|
|
|
|
|
|
|
|
import NavDropdown from 'react-bootstrap/NavDropdown';
|
|
|
|
|
|
|
|
|
|
|
|
export default function NavBar() {
|
|
|
|
export default function NavBar() {
|
|
|
|
const [anchorEl, setAnchorEl] = React.useState(null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleLogin = () => {
|
|
|
|
const handleLogin = () => {
|
|
|
|
handleClose();
|
|
|
|
|
|
|
|
window.location.href='/login';
|
|
|
|
window.location.href='/login';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const handleSignup = () => {
|
|
|
|
const handleSignup = () => {
|
|
|
|
handleClose();
|
|
|
|
|
|
|
|
window.location.href='/signup';
|
|
|
|
window.location.href='/signup';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const handleLogout= () => {
|
|
|
|
const handleLogout= () => {
|
|
|
|
handleClose();
|
|
|
|
|
|
|
|
document.cookie.split(";").forEach(function(c) { document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/"); });
|
|
|
|
document.cookie.split(";").forEach(function(c) { document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/"); });
|
|
|
|
window.location.href='/welcome';
|
|
|
|
window.location.href='/welcome';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const handleMenu = (event) => {
|
|
|
|
|
|
|
|
setAnchorEl(event.currentTarget);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleClose = () => {
|
|
|
|
|
|
|
|
setAnchorEl(null);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Toolbar position="sticky" className="bar">
|
|
|
|
<Toolbar position="sticky" className="bar">
|
|
|
|
<Link href="/" class="nav-brand">
|
|
|
|
<Link href="/" className="nav-brand">
|
|
|
|
<img src={logo} className="logo"/>
|
|
|
|
<img src={logo} className="logo w-100"/>
|
|
|
|
<Typography
|
|
|
|
<Typography
|
|
|
|
className="nav-header"
|
|
|
|
className="nav-header"
|
|
|
|
variant="h5" >
|
|
|
|
variant="h5" >
|
|
|
|
@ -47,39 +36,17 @@ export default function NavBar() {
|
|
|
|
{checkLogin()
|
|
|
|
{checkLogin()
|
|
|
|
? // Logged In
|
|
|
|
? // Logged In
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
<IconButton
|
|
|
|
<NavDropdown title={`Logged in as ${getFirstName()}`}>
|
|
|
|
size="large"
|
|
|
|
<NavDropdown.Item>Profile</NavDropdown.Item>
|
|
|
|
aria-label="account of current user"
|
|
|
|
<NavDropdown.Item>My account</NavDropdown.Item>
|
|
|
|
aria-controls="menu-appbar"
|
|
|
|
<NavDropdown.Item onClick={handleLogout}>Sign Out</NavDropdown.Item>
|
|
|
|
aria-haspopup="true"
|
|
|
|
</NavDropdown>
|
|
|
|
onClick={handleMenu}
|
|
|
|
|
|
|
|
color="inherit" >
|
|
|
|
|
|
|
|
<AccountCircle />
|
|
|
|
|
|
|
|
</IconButton>
|
|
|
|
|
|
|
|
<Menu
|
|
|
|
|
|
|
|
id="menu-appbar"
|
|
|
|
|
|
|
|
anchorEl={anchorEl}
|
|
|
|
|
|
|
|
anchorOrigin={{
|
|
|
|
|
|
|
|
vertical: 'top',
|
|
|
|
|
|
|
|
horizontal: 'right',
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
keepMounted
|
|
|
|
|
|
|
|
transformOrigin={{
|
|
|
|
|
|
|
|
vertical: 'top',
|
|
|
|
|
|
|
|
horizontal: 'right',
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
open={Boolean(anchorEl)}
|
|
|
|
|
|
|
|
onClose={handleClose} >
|
|
|
|
|
|
|
|
<MenuItem onClick={handleClose}>Profile</MenuItem>
|
|
|
|
|
|
|
|
<MenuItem onClick={handleClose}>My account</MenuItem>
|
|
|
|
|
|
|
|
<MenuItem onClick={handleLogout}>Log Out</MenuItem>
|
|
|
|
|
|
|
|
</Menu>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
: // Logged Out
|
|
|
|
: // Logged Out
|
|
|
|
<span style={{display: "flex"}}>
|
|
|
|
<span className="mx-0" style={{display: "flex"}}>
|
|
|
|
<Button onClick={handleLogin}>Login</Button>
|
|
|
|
<Button className="mx-0" onClick={handleLogin}>Login</Button>
|
|
|
|
<p style={{marginTop: "9px"}}>or</p>
|
|
|
|
<p style={{marginTop: "9px"}}>or</p>
|
|
|
|
<Button onClick={handleSignup}>Signup</Button>
|
|
|
|
<Button className="mx-0" onClick={handleSignup}>Signup</Button>
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|