Bladeren bron

fix sidebar

Tanya Sashyna 5 jaren geleden
bovenliggende
commit
7a2d4523e0
1 gewijzigde bestanden met toevoegingen van 6 en 4 verwijderingen
  1. 6 4
      src/components/sidebar/Sidebar.js

+ 6 - 4
src/components/sidebar/Sidebar.js

@@ -44,7 +44,9 @@ export class Sidebar extends React.Component {
 
     render() {
         
-	    const { showSidebar, showSidebarFlag } = this.props;
+        const { showSidebar, showSidebarFlag } = this.props;
+        const role = localStorage.user && JSON.parse(localStorage.user).user.role;
+
         return (
             <div className={ !showSidebarFlag ? 'menu close' : 'menu' }>
                 <nav>
@@ -55,7 +57,7 @@ export class Sidebar extends React.Component {
                     </div>
                     <ul>
 						{
-                            localStorage.user && <li><Link to="/profile">Profile</Link></li>
+                            role && <li><Link to="/profile">Profile</Link></li>
 						}
 						
                         {
@@ -66,10 +68,10 @@ export class Sidebar extends React.Component {
                             )
                         }
 						{
-                            !localStorage.user && <li><Link to="/login">Login</Link></li>
+                            !role && <li><Link to="/login">Login</Link></li>
 						}
                         {
-                            localStorage.user && <li>
+                            role && <li>
                                 <button className="logout" onClick={this.logoutHandler}>
                                     <i className="fa fa-sign-out"></i>
                                 </button>