-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
61 lines (57 loc) · 1.68 KB
/
app.js
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import React, { Component } from 'react'
import { HashRouter, Route } from 'react-router-dom'
import { connect } from 'react-redux'
import { Nav, NavItem } from 'react-bootstrap'
import { LinkContainer } from 'react-router-bootstrap'
import { login, logout } from './../actions/auth'
@connect(store => {
return {
pages: (store.pages && store.pages.pages) ? store.pages.pages : [],
isAuthenticated: store.auth.isAuthenticated
}
}, dispatch => {
const onLogin = () => dispatch(login)
const onLogout = () => dispatch(logout)
// use RxJS to do this kinda stuff
window.streamAuthStatus(onLogin, onLogout)
return {}
})
export default class App extends Component {
render () {
if (this.props.isAuthenticated) {
return (
<HashRouter>
<div>
<div id='nav'>
<Nav bsStyle='pills' activeKey={1} >
{
this.props.pages.map((page, i) => {
return (
<LinkContainer to={page.href} key={i} >
<NavItem eventKey={i}>{page.title}</NavItem>
</LinkContainer>
)
})
}
</Nav>
</div>
{
this.props.pages.map((page, i) => {
return (
<div className='page' key={i}>
<Route path={page.href} component={page} />
</div>
)
})
}
</div>
</HashRouter>)
} else if (this.props.isAuthenticated === false) {
return <div>Please login</div>
} else {
return (
<div>Loading ...</div>
)
}
}
}