- Fix hitting dashboard when logged out
- Clean up app.js
This commit is contained in:
Daniel Mason 2021-03-30 23:03:40 +13:00
parent 2f8aa2e502
commit 0c56281bcd
Signed by: idanoo
GPG key ID: 387387CDBC02F132
7 changed files with 40 additions and 46 deletions

View file

@ -30,10 +30,11 @@ class Navigation extends Component {
constructor(props) {
super(props);
this.toggleNavbar = this.toggleNavbar.bind(this);
this.handleLogout = this.handleLogout.bind(this);
// Yeah I know you might not hit home.. but I can't get the
// path based finder thing working on initial load :sweatsmile:
this.state = { active: "Home", collapsed: true};
this.state = { active: "Home", collapsed: true };
}
componentDidMount() {
@ -55,13 +56,16 @@ class Navigation extends Component {
componentWillUnmount() {
eventBus.remove(LOGIN_SUCCESS);
eventBus.remove(LOGOUT);
}
_handleClick(menuItem) {
this.setState({ active: menuItem, collapsed: !this.state.collapsed });
}
handleLogout() {
this.dispatch(logout());
}
toggleNavbar() {
this.setState({ collapsed: !this.state.collapsed });
}
@ -94,7 +98,7 @@ class Navigation extends Component {
onClick={this._handleClick.bind(this, "profile")}
className="navLinkMobile"
>Profile</Link>
<Link to="/" className="navLink" onClick={logout()}>Logout</Link>
<Link to="/" className="navLink" onClick={this.handleLogout}>Logout</Link>
</Nav>
: <Nav className="navLinkLoginMobile" navbar>
{menuItems.map(menuItem =>
@ -172,7 +176,7 @@ class Navigation extends Component {
onClick={this._handleClick.bind(this, "profile")}
className="navLink"
>Profile</Link>
<Link to="/" className="navLink" onClick={logout()}>Logout</Link>
<Link to="/" className="navLink" onClick={this.handleLogout}>Logout</Link>
</div>
:
<div className="navLinkLogin">
@ -209,8 +213,9 @@ class Navigation extends Component {
function mapStateToProps(state) {
const { isLoggedIn } = state.auth;
return {
isLoggedIn,
isLoggedIn
};
}