diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2020-09-26 15:30:15 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2020-09-26 15:30:15 +0200 |
| commit | d260e3a65bdec981fd98db8a2352caa9bef9ae55 (patch) | |
| tree | ce04d69a1ed647c89b5dab93391c383d6beff14f /frontend/app/router.js | |
| parent | a17b76ac75f506f5da6fe8adf9c36632b60d4226 (diff) | |
finalizing fixing refactor!!
Diffstat (limited to 'frontend/app/router.js')
| -rw-r--r-- | frontend/app/router.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/frontend/app/router.js b/frontend/app/router.js new file mode 100644 index 0000000..8dbbd0f --- /dev/null +++ b/frontend/app/router.js @@ -0,0 +1,44 @@ +import React, { Component } from 'react' +import { ConnectedRouter } from 'connected-react-router' +import { Route } from 'react-router' + +// import actions from 'app/actions' + +import * as views from 'app/views' + +const viewList = Object.keys(views).map(name => { + const view = views[name] + let path, exact = false + if (name === 'graph') { + path = '/:graph_name' + exact = true + } else if (name === 'page') { + path = '/:graph_name/:page_name' + exact = true + } else { + path = '/' + name + } + return ( + <Route key={name} path={path} component={view} exact={exact} /> + ) +}) + +export default class App extends Component { + componentDidMount() { + // actions.modelzoo.index() + } + render() { + return ( + <ConnectedRouter history={this.props.history}> + <div className='app'> + {viewList} + <Route exact key='root' path='/' render={() => { + // redirect to index!! + setTimeout(() => this.props.history.push('/index'), 10) + return null + }} /> + </div> + </ConnectedRouter> + ) + } +} |
