|
@@ -1,58 +1,77 @@
|
|
|
import React from 'react';
|
|
|
import { Link } from "react-router-dom";
|
|
|
+import { connect } from 'react-redux';
|
|
|
+import { bindActionCreators } from 'redux';
|
|
|
+
|
|
|
import * as routes from '../../constants/routes'
|
|
|
+import logOut from './../../actions/auth/logOut';
|
|
|
+
|
|
|
+class Header extends React.Component {
|
|
|
+ handleLogOut = () => {
|
|
|
+ const { logOut } = this.props;
|
|
|
+ logOut()
|
|
|
+ //TODO: REDIRECT
|
|
|
+ }
|
|
|
|
|
|
-export default class Header extends React.Component {
|
|
|
render() {
|
|
|
return (
|
|
|
<nav class="navbar navbar-expand-lg navbar-dark bg-dark p-3">
|
|
|
- <a class="navbar-brand" href="#">Test.io</a>
|
|
|
+ <Link to={routes.LANDING} class="navbar-brand" href="#">Test.io</Link>
|
|
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
|
|
- <span class="navbar-toggler-icon"></span>
|
|
|
+ <span class="navbar-toggler-icon" />
|
|
|
</button>
|
|
|
|
|
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
|
|
<ul class="navbar-nav mr-auto">
|
|
|
<li class="nav-item active">
|
|
|
- <Link onClick={this.handleClick} class="nav-link font-ci font-ci-bold" to={routes.HOME}>Home <span class="sr-only">(current)</span></Link>
|
|
|
+ <Link onClick={this.handleClick} class="nav-link" to={routes.HOME}>Home <span class="sr-only">(current)</span></Link>
|
|
|
</li>
|
|
|
<li class="nav-item">
|
|
|
- <Link onClick={this.handleClick} class="nav-link font-ci font-ci-bold" to={routes.PROFILE}>Profile</Link>
|
|
|
+ <Link onClick={this.handleClick} class="nav-link" to={routes.PROFILE}>Profile</Link>
|
|
|
</li>
|
|
|
<li class="nav-item">
|
|
|
- <Link onClick={this.handleClick} class="nav-link font-ci font-ci-bold " to={routes.TESTS}>Tests</Link>
|
|
|
+ <Link onClick={this.handleClick} class="nav-link" to={routes.TESTS}>Tests</Link>
|
|
|
</li>
|
|
|
<li class="nav-item">
|
|
|
- <Link onClick={this.handleClick} class="nav-link font-ci font-ci-bold " to={routes.CATEGORIES}>Catigories</Link>
|
|
|
+ <Link onClick={this.handleClick} class="nav-link" to={routes.CATEGORIES}>Catigories</Link>
|
|
|
</li>
|
|
|
{/* TODO: admin-only ! */}
|
|
|
<li class="nav-item dropdown">
|
|
|
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
|
|
Dropdown
|
|
|
- </a>
|
|
|
+ </a>
|
|
|
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
|
|
- <a class="dropdown-item" href="#">Action</a>
|
|
|
- <a class="dropdown-item" href="#">Another action</a>
|
|
|
+ <Link to={routes.CREATE_TEST} className="nav-link text-secondary">Create Test</Link>
|
|
|
+ <Link to={routes.CREATE_CATEGORY} className="nav-link text-secondary">Create Category</Link>
|
|
|
+
|
|
|
<div class="dropdown-divider"></div>
|
|
|
- <a class="dropdown-item" href="#">Something else here</a>
|
|
|
+ <a class="nav-link text-secondary" href="#">Something else here</a>
|
|
|
</div>
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
- <form class="form-inline my-2 my-lg-0">
|
|
|
+ <form class="form-inline my-lg-0">
|
|
|
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search" />
|
|
|
- <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
|
|
|
+ <button class="btn btn-outline-success my-2 my-sm-0 mr-2" type="submit">Search</button>
|
|
|
</form>
|
|
|
- <div className="pl-2">
|
|
|
+ <div className="">
|
|
|
<Link to={routes.SIGN_IN}>
|
|
|
<button className="btn btn-outline-primary">Sign In</button>
|
|
|
</Link>
|
|
|
<Link to={routes.SIGN_UP}>
|
|
|
- <button className="btn btn-outline-primary ml-2">Sign Up</button>
|
|
|
+ <button className="btn btn-outline-primary mx-2">Sign Up</button>
|
|
|
</Link>
|
|
|
+ <button onClick={this.handleLogOut} className="btn btn-outline-primary">Log Out</button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</nav>
|
|
|
)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+const mapStateToProps = state => ({
|
|
|
+ state: state.logOut
|
|
|
+});
|
|
|
+const mapDispatchToProps = dispatch => bindActionCreators({ logOut }, dispatch)
|
|
|
+
|
|
|
+export default connect(mapStateToProps, mapDispatchToProps)(Header);
|