Skip to content

Commit

Permalink
Merge b8d860d into 09908a0
Browse files Browse the repository at this point in the history
  • Loading branch information
nouwatinjacob committed Oct 9, 2018
2 parents 09908a0 + b8d860d commit cde122f
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 9 deletions.
31 changes: 22 additions & 9 deletions client/src/modules/common/Navbar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class Navbar extends Component {

render() {
const { showSearchBar, name } = this.state;
const role = localStorage.getItem("role");
const {
showTabs, switchContent, showIcon, gotoHome
} = this.props;
Expand Down Expand Up @@ -102,6 +103,27 @@ class Navbar extends Component {
</a>
</li>
)}
{
role === 'admin' ?
<li>
<NavLink to="/teams/create">
{/* Create team */}
<i className="material-icons" data-tip="Create teams">
group_add
</i>
</NavLink>
</li> :
<li>
<button className="admin-request-btn">
<i
className="tiny material-icons"
data-tip="Only LFs can make this request">
info
</i>
Request admin privilege
</button>
</li>
}
<li>
<NavLink to="/teams" onClick={this.props.gotoHome}>
{/* Teams */}
Expand All @@ -110,15 +132,6 @@ class Navbar extends Component {
</i>
</NavLink>
</li>

<li>
<NavLink to="/teams/create">
{/* Create team */}
<i className="material-icons" data-tip="Create teams">
group_add
</i>
</NavLink>
</li>
<li>
<NavLink to="/teams/favorites">
{/* Favorite teams */}
Expand Down
5 changes: 5 additions & 0 deletions client/src/redux/actions/auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ export const signIn = data => dispatch => {
}
} = response;
const { data: { data: { user: { id } } } } = response;
const { data: { data: { user: { role } } } } = response;
localStorage.setItem('aTeamsToken', userToken);
localStorage.setItem('userId', id);
localStorage.setItem('role', role);
successMessage('Login successful');
}

Expand All @@ -48,7 +50,9 @@ export const signUp = data => dispatch => {
data: { userToken }
}
} = response;
const { data: { data: { user: { role } } } } = response;
localStorage.setItem('aTeamsToken', userToken);
localStorage.setItem('role', role);
successMessage('Registration successful');
dispatch(success(SIGN_UP, response.data));
return;
Expand All @@ -68,6 +72,7 @@ export const signUp = data => dispatch => {
export const signOut = data => dispatch => {
dispatch(isLoading(true));
localStorage.removeItem('aTeamsToken');
localStorage.removeItem('role');
dispatch(isLoading(false));
dispatch(isAuthenticated());
successMessage('Signed out successfully');
Expand Down
24 changes: 24 additions & 0 deletions client/styles/components/_navbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,27 @@
.tabs .tab a:focus.active {
background: transparent;
}


.admin-request-btn {
position: relative;
margin-right: 20px;
padding: 8px 30px 8px 15px;
border-radius: 15px;
cursor: pointer;
background-color: #385cd7;
color: #ffffff;
}


.admin-request-btn {
.material-icons {
position: absolute;
top: 50%;
right: 3px;
transform: translateY(-50%);
color: #ffffff;
font-size:18px !important;
margin-right: 5px;
}
}

0 comments on commit cde122f

Please sign in to comment.