|
|
@@ -11,39 +11,51 @@ import {
|
|
11
|
11
|
withRouter
|
|
12
|
12
|
} from 'react-router-dom'
|
|
13
|
13
|
import PrivateRoute from './PrivateRoute.jsx'
|
|
|
14
|
+import { getIsUserConnected } from '../action-creator.async.js'
|
|
14
|
15
|
|
|
15
|
16
|
const SidebarWrapper = props => {
|
|
16
|
|
- if (props.locationPath !== '/login') {
|
|
17
|
|
- return (
|
|
18
|
|
- <div className='sidebarpagecontainer'>
|
|
19
|
|
- <Sidebar />
|
|
20
|
|
- {props.children}
|
|
21
|
|
- </div>
|
|
22
|
|
- )
|
|
23
|
|
- } else return props.children
|
|
|
17
|
+ if (props.locationPath !== '/login') return (
|
|
|
18
|
+ <div className='sidebarpagecontainer'>
|
|
|
19
|
+ <Sidebar />
|
|
|
20
|
+ {props.children}
|
|
|
21
|
+ </div>
|
|
|
22
|
+ )
|
|
|
23
|
+ else return props.children
|
|
24
|
24
|
}
|
|
25
|
25
|
|
|
26
|
26
|
class Tracim extends React.Component {
|
|
|
27
|
+ componentDidMount = () => {
|
|
|
28
|
+ this.props.dispatch(getIsUserConnected())
|
|
|
29
|
+ }
|
|
|
30
|
+
|
|
27
|
31
|
render () {
|
|
28
|
|
- const { location } = this.props
|
|
|
32
|
+ const { user, location } = this.props
|
|
|
33
|
+
|
|
29
|
34
|
return (
|
|
30
|
35
|
<div>
|
|
31
|
36
|
<Header />
|
|
32
|
37
|
|
|
33
|
|
- <Route path='/login' component={Login} />
|
|
|
38
|
+ { user.isLoggedIn === undefined
|
|
|
39
|
+ ? (<div />) // while we dont know if user is connected, display nothing but the header @TODO show loader
|
|
|
40
|
+ : (
|
|
|
41
|
+ <div>
|
|
|
42
|
+ <Route path='/login' component={Login} />
|
|
34
|
43
|
|
|
35
|
|
- <SidebarWrapper locationPath={location.pathname}>
|
|
|
44
|
+ <SidebarWrapper locationPath={location.pathname}>
|
|
36
|
45
|
|
|
37
|
|
- <PrivateRoute exact path='/' component={WorkspaceContent} />
|
|
38
|
|
- <PrivateRoute path='/page' component={Page} />
|
|
|
46
|
+ <PrivateRoute exact path='/' component={WorkspaceContent} />
|
|
|
47
|
+ <PrivateRoute path='/page' component={Page} />
|
|
39
|
48
|
|
|
40
|
|
- </SidebarWrapper>
|
|
|
49
|
+ </SidebarWrapper>
|
|
41
|
50
|
|
|
42
|
|
- <Footer />
|
|
|
51
|
+ <Footer />
|
|
|
52
|
+ </div>
|
|
|
53
|
+ )
|
|
|
54
|
+ }
|
|
43
|
55
|
</div>
|
|
44
|
56
|
)
|
|
45
|
57
|
}
|
|
46
|
58
|
}
|
|
47
|
59
|
|
|
48
|
|
-const mapStateToProps = () => ({})
|
|
|
60
|
+const mapStateToProps = ({ user }) => ({ user })
|
|
49
|
61
|
export default withRouter(connect(mapStateToProps)(Tracim))
|