diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2020-07-22 14:05:15 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2020-07-22 14:05:15 +0200 |
| commit | ef78bc6a084f92b4794e987b5832240d85b6479e (patch) | |
| tree | b314b630800db6aa60f28ef0b115625e6ca176db /animism-align/frontend/app/router.js | |
| parent | 85d4cb9addf9ca887d3440b2786665d67d9917c4 (diff) | |
refactor app using babel module-resolver
Diffstat (limited to 'animism-align/frontend/app/router.js')
| -rw-r--r-- | animism-align/frontend/app/router.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/animism-align/frontend/app/router.js b/animism-align/frontend/app/router.js new file mode 100644 index 0000000..bd87cbe --- /dev/null +++ b/animism-align/frontend/app/router.js @@ -0,0 +1,42 @@ +import React, { Component } from 'react' +import { ConnectedRouter } from 'connected-react-router' +import { Route } from 'react-router' + +import actions from 'app/actions' + +import Header from 'app/views/nav/header.component' +import * as views from 'app/views' + +const viewList = Object.keys(views).map(name => { + const view = views[name] + let path, exact = false + path = '/' + name + return ( + <Route key={name} path={path} component={view} exact={exact} /> + ) +}) + +export default class Router extends Component { + componentDidMount() { + actions.site.loadText() + actions.site.loadPeaks() + actions.annotation.index() + actions.paragraph.index() + actions.media.index() + } + render() { + return ( + <ConnectedRouter history={this.props.history}> + <div className='app'> + <Header /> + {viewList} + <Route exact key='root' path='/' render={() => { + // redirect to index!! + setTimeout(() => this.props.history.push('/align'), 10) + return null + }} /> + </div> + </ConnectedRouter> + ) + } +} |
