sider.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import React, { useContext } from 'react';
  2. import { NavLink as NavLinkRouter } from "react-router-dom";
  3. import {store} from "../../context/store";
  4. import {USER_LOGGED_OUT} from "../../context/actionType";
  5. import { Menu } from 'antd';
  6. export default function SideMenu(props) {
  7. const {isLoggedIn, userName, userRole, dispatch} = useContext(store);
  8. const onLogout = () => {
  9. dispatch({type: USER_LOGGED_OUT})
  10. }
  11. return (
  12. <div style={{ backgroundColor: "#002329", color: "white" }}>
  13. <div className="text-right p-3" style={{ minHeight: "150px" }}>
  14. <div className="d-flex justify-content-between" style={{ minHeight: "150px" }}>
  15. <div>
  16. <h4 className="text-white">
  17. <NavLinkRouter className="text-white text-decoration-none" to="/">
  18. پورتال
  19. </NavLinkRouter>
  20. </h4>
  21. </div>
  22. <div className="align-self-end">
  23. <span className="pointer" onClick={() => onLogout()} >خروج از حساب</span>
  24. </div>
  25. </div>
  26. </div>
  27. <Menu
  28. mode="inline"
  29. // defaultSelectedKeys={['1']}
  30. style={{ height: '100%', borderRight: 0, backgroundColor: "#002329", color: "white" }}
  31. >
  32. <Menu.Item key="1">
  33. <NavLinkRouter className="text-white text-decoration-none" to="/exams">
  34. آزمون ها
  35. </NavLinkRouter>
  36. </Menu.Item>
  37. {
  38. userRole !== "student" && (
  39. <>
  40. <Menu.Item key="2">
  41. <NavLinkRouter className="text-white text-decoration-none" to="/sets">
  42. امتحانات
  43. </NavLinkRouter>
  44. </Menu.Item>
  45. </>
  46. )
  47. }
  48. </Menu>
  49. </div>
  50. )
  51. }