adminHeader.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import React from 'react';
  2. import { Link, withRouter } from 'react-router-dom';
  3. import './adminHeader.scss';
  4. import { adminMenu } from '../../state/adminMenu';
  5. const adminHeader = (props) => {
  6. const logout = (e) => {
  7. localStorage.removeItem('user');
  8. props.history.push('/');
  9. };
  10. const clickEventHandler = (e) => {
  11. props.changeEditFlag();
  12. };
  13. return (
  14. <header className="header" id="header">
  15. <div className="header__left-wrapper">
  16. <div className="header__logo-box">
  17. <div className="header__logo">
  18. <Link to="/admin">
  19. Just_<span>tri</span>_it
  20. </Link>
  21. </div>
  22. </div>
  23. <nav className="header__nav">
  24. <ul className="header__list">
  25. {adminMenu.map(
  26. (el) =>
  27. el.hideWhenAuth && props.user ? null : (
  28. <li
  29. className="header__item"
  30. key={el.id}
  31. onClick={el.logout ? logout : clickEventHandler}
  32. >
  33. <Link to={el.path}>{el.text}</Link>
  34. </li>
  35. )
  36. )}
  37. </ul>
  38. </nav>
  39. </div>
  40. </header>
  41. );
  42. };
  43. export default withRouter(adminHeader);