Skip to content

Instantly share code, notes, and snippets.

@allanice001
Created June 26, 2020 05:09
Show Gist options
  • Save allanice001/2e57a7c9fff12a6dd12b86465e8fb6bc to your computer and use it in GitHub Desktop.
Save allanice001/2e57a7c9fff12a6dd12b86465e8fb6bc to your computer and use it in GitHub Desktop.
import React from 'react';
import { AuthContext, AppNav, Header, HoverNav, Button } from 'components/lib';
import ClassNames from 'classnames';
import '../layout.scss';
import './app.scss';
export class AppLayout extends React.Component {
constructor() {
super();
this.user = JSON.parse(localStorage.getItem('user'));
}
render(){
// remove the background color applied from the homepage
document.body.classList.remove('color-bg');
const cssClass = ClassNames({
'app': true,
'with-sidebar': true,
'with-bottom-nav': true,
'hide': this.props.loading
});
return (
<>
<AppNav
type='fixed'
items={[
{ label: 'Dashboard', link: '/dashboard' },
{ label: 'Customer Rewards', link: '/customer', hasSubNav: true }
]}
/>
<main className={ cssClass }>
<Header title={ this.props.title }>
<HoverNav label={ this.context.user.username ? this.context.user.username : this.context.user.email } align='right'>
<Button text='Account Settings' action={ event => window.location = '/account' }/>
{this.user.permission === 'admin' &&
<Button text='Master Dashboard' action={ event => window.location = '/master' }/>
}
<Button text='Signout' action={ this.context.signout }/>
</HoverNav>
</Header>
{ <this.props.children/> }
</main>
</>
);
}
}
AppLayout.contextType = AuthContext;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment