forked from StephenGrider/FullstackReactCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHeader.js
More file actions
47 lines (43 loc) · 1.08 KB
/
Header.js
File metadata and controls
47 lines (43 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Link } from 'react-router-dom';
import Payments from './Payments';
class Header extends Component {
renderContent() {
switch (this.props.auth) {
case null:
return;
case false:
return <li><a href="/auth/google">Login With Google</a></li>;
default:
return [
<li key="1"><Payments /></li>,
<li key="3" style={{ margin: '0 10px' }}>
Credits: {this.props.auth.credits}
</li>,
<li key="2"><a href="/api/logout">Logout</a></li>
];
}
}
render() {
return (
<nav>
<div className="nav-wrapper">
<Link
to={this.props.auth ? '/surveys' : '/'}
className="left brand-logo"
>
Emaily
</Link>
<ul className="right">
{this.renderContent()}
</ul>
</div>
</nav>
);
}
}
function mapStateToProps({ auth }) {
return { auth };
}
export default connect(mapStateToProps)(Header);