|
@@ -5,81 +5,93 @@ import * as routes from './../../../constants/routes';
|
|
|
import token from './../../../utils/token';
|
|
|
|
|
|
export default class header extends Component {
|
|
|
+ /*
|
|
|
+ TODO:
|
|
|
+ - add toggler for admin panel
|
|
|
+ - disable marking and background hover effect in the nav panel
|
|
|
+ */
|
|
|
|
|
|
state = {
|
|
|
- togglerClosed: true
|
|
|
+ navTogglerClosed: true,
|
|
|
+ adminToggleClosed: true
|
|
|
}
|
|
|
|
|
|
- handleClick = () => {
|
|
|
+ handleLinkClick = () => {
|
|
|
this.setState({ togglerClosed: true })
|
|
|
}
|
|
|
|
|
|
- handleToggle = event => {
|
|
|
- this.setState((prevState) => ({ togglerClosed: !prevState.togglerClosed }))
|
|
|
+ handleNavToggle = () => {
|
|
|
+ this.setState((prevState) => ({ navTogglerClosed: !prevState.navTogglerClosed }))
|
|
|
+ }
|
|
|
+
|
|
|
+ handleAdminToggle = () => {
|
|
|
+ this.setState({
|
|
|
+
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
handleSignOut = () => {
|
|
|
- console.log("signOut", this.props);
|
|
|
this.props.signOut();
|
|
|
localStorage.removeItem(token);
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
- const { togglerClosed } = this.state;
|
|
|
+ const { navTogglerClosed, adminToggleClosed } = this.state;
|
|
|
const { user: { data } } = this.props;
|
|
|
- const toggleStatus = togglerClosed ? "toggle-status--closed" : "toggle-status--opened";
|
|
|
+ const navToggleStatus = navTogglerClosed ? "nav-toggle-status--closed" : "nav-toggle-status--opened";
|
|
|
+ const adminToggleStatus = adminToggleClosed ? "admin-toggle-status--closed" : "admin-toggle-status--opened";
|
|
|
|
|
|
return (
|
|
|
<header className="header">
|
|
|
- <Link onClick={this.handleClick} to={routes.LANDING}>
|
|
|
+ <Link onClick={this.handleLinkClick} to={routes.LANDING}>
|
|
|
<h1 className="header__logo">Test.<span className="header__logo--i-letter">i</span>o</h1>
|
|
|
</Link>
|
|
|
<hr className="header__logo--divider" />
|
|
|
- <span className="header__toggle-trigger" onClick={this.handleToggle} >
|
|
|
+ <span className="header__toggle-trigger" onClick={this.handleNavToggle} >
|
|
|
<span />
|
|
|
</span>
|
|
|
<div className="header__flex-wrapper">
|
|
|
- <nav className={`header__nav ${toggleStatus}`}>
|
|
|
- <ul className="header__nav nav__list" >
|
|
|
+ <nav className={`header__nav ${navToggleStatus}`}>
|
|
|
+ <ul className="header__nav nav__list">
|
|
|
<li>
|
|
|
- <Link onClick={this.handleClick} className="header__nav nav__list-item" to={routes.HOME}>
|
|
|
+ <Link onClick={this.handleLinkClick} className="header__nav nav__list-item" to={routes.HOME}>
|
|
|
Home
|
|
|
</Link>
|
|
|
</li>
|
|
|
<li>
|
|
|
- <Link onClick={this.handleClick} className="header__nav nav__list-item" to={routes.PROFILE}>
|
|
|
+ <Link onClick={this.handleLinkClick} className="header__nav nav__list-item" to={routes.PROFILE}>
|
|
|
Profile
|
|
|
</Link>
|
|
|
</li>
|
|
|
<li>
|
|
|
- <Link onClick={this.handleClick} className="header__nav nav__list-item" to={routes.TESTS}>
|
|
|
+ <Link onClick={this.handleLinkClick} className="header__nav nav__list-item" to={routes.TESTS}>
|
|
|
Test
|
|
|
</Link>
|
|
|
</li>
|
|
|
<li>
|
|
|
- <Link onClick={this.handleClick} className="header__nav nav__list-item" to={routes.CATEGORIES}>
|
|
|
+ <Link onClick={this.handleLinkClick} className="header__nav nav__list-item" to={routes.CATEGORIES}>
|
|
|
Categories
|
|
|
</Link>
|
|
|
</li>
|
|
|
{
|
|
|
data && data.is_admin && (
|
|
|
- <React.Fragment>
|
|
|
+ <div className={`header__nav ${adminToggleStatus}`}>
|
|
|
<li>
|
|
|
- <Link onClick={this.handleClick} className="header__nav nav__list-item--admin-only" to={routes.CREATE_TEST}>
|
|
|
+ <Link onClick={this.handleLinkClick} className="header__nav nav__list-item--admin-only" to={routes.CREATE_TEST}>
|
|
|
Create test
|
|
|
</Link>
|
|
|
</li>
|
|
|
<li>
|
|
|
- <Link onClick={this.handleClick} className="header__nav nav__list-item--admin-only" to={routes.CREATE_CATEGORY}>
|
|
|
+ <Link onClick={this.handleLinkClick} className="header__nav nav__list-item--admin-only" to={routes.CREATE_CATEGORY}>
|
|
|
Create category
|
|
|
</Link>
|
|
|
</li>
|
|
|
<li>
|
|
|
- <Link onClick={this.handleClick} className="header__nav nav__list-item--admin-only" to={routes.DELETE_USER}>
|
|
|
+ <Link onClick={this.handleLinkClick} className="header__nav nav__list-item--admin-only" to={routes.DELETE_USER}>
|
|
|
Delete data
|
|
|
</Link>
|
|
|
</li>
|
|
|
- </React.Fragment>
|
|
|
+ </div>
|
|
|
)
|
|
|
}
|
|
|
</ul>
|
|
@@ -90,8 +102,8 @@ export default class header extends Component {
|
|
|
!data
|
|
|
? (
|
|
|
<React.Fragment>
|
|
|
- <Link onClick={this.handleClick} className="header__links--sign-in link--btn link--btn25" to={routes.SIGN_IN}>Sign in</Link>
|
|
|
- <Link onClick={this.handleClick} className="header__links--sign-up link--btn link--btn25" to={routes.SIGN_UP}>Sign up</Link>
|
|
|
+ <Link onClick={this.handleLinkClick} className="header__links--sign-in link--btn link--btn25" to={routes.SIGN_IN}>Sign in</Link>
|
|
|
+ <Link onClick={this.handleLinkClick} className="header__links--sign-up link--btn link--btn25" to={routes.SIGN_UP}>Sign up</Link>
|
|
|
</React.Fragment>
|
|
|
)
|
|
|
: (
|