adminMenu.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import React, { Component } from "react";
  2. import { withRouter } from "react-router-dom";
  3. import "./adminMenu.scss";
  4. import { adminMenu } from "../../state/adminMenu";
  5. class AdminMenu extends Component {
  6. constructor(props) {
  7. super(props);
  8. this.state = {adminMenu};
  9. }
  10. clickEventHandler = (e) => {
  11. const elem = adminMenu.find(el => el.id === +e.target.id)
  12. this.props.history.push(elem.path)
  13. }
  14. render(){
  15. return(
  16. <div className = "menu-block">
  17. {adminMenu.map(el =>
  18. el.text !== "Log out" && el.text !== "Main Page" &&
  19. <div
  20. className="menu-skew"
  21. path = {el.path}
  22. key={el.id}
  23. id = {el.id}
  24. onClick = {this.clickEventHandler}
  25. >
  26. <h2 className = "menu-text">{el.text.toUpperCase()}</h2>
  27. {/* <Link to={el.path} className = "menu-text"> {el.text.toUpperCase()} </Link> */}
  28. </div>
  29. )
  30. }
  31. </div>
  32. )
  33. }
  34. }
  35. export default withRouter(AdminMenu)