75 lines
1.9 KiB
JavaScript
Raw Normal View History

/**
*
* This component is the skeleton around the actual pages, and should only
* contain code that should be seen on all pages. (e.g. navigation bar)
*
*/
import React from 'react';
import PropTypes from 'prop-types';
// import { connect } from 'react-redux';
import { Switch, Route } from 'react-router-dom';
// import { bindActionCreators, compose } from 'redux';
// Utils
import { pluginId } from 'app';
// Containers
import AuthPage from 'containers/AuthPage';
import EditPage from 'containers/EditPage';
import HomePage from 'containers/HomePage';
import NotFoundPage from 'containers/NotFoundPage';
class App extends React.Component {
2017-11-06 12:27:53 +01:00
componentDidMount() {
if (!this.props.location.pathname.split('/')[3]) {
this.props.history.push('/plugins/users-permissions/roles');
}
}
componentDidUpdate() {
if (!this.props.location.pathname.split('/')[3]) {
2017-11-06 12:27:53 +01:00
this.props.history.push('/plugins/users-permissions/roles');
}
}
render() {
return (
<div className={pluginId}>
<Switch>
<Route path={`/plugins/${pluginId}/auth/:authType/:id?`} component={AuthPage} exact />
<Route path={`/plugins/${pluginId}/:settingType/:actionType/:id?`} component={EditPage} exact />
2017-11-06 12:27:53 +01:00
<Route path={`/plugins/${pluginId}/:settingType`} component={HomePage} exact />
<Route component={NotFoundPage} />
</Switch>
</div>
);
}
}
App.contextTypes = {
plugins: PropTypes.object,
router: PropTypes.object.isRequired,
updatePlugin: PropTypes.func,
};
App.propTypes = {
history: PropTypes.object.isRequired,
2017-11-06 12:27:53 +01:00
location: PropTypes.object.isRequired,
};
// export function mapDispatchToProps(dispatch) {
// return bindActionCreators(
// {},
// dispatch,
// );
// }
// Wrap the component to inject dispatch and state into it
// const withConnect = connect(null, mapDispatchToProps);
export default App;
// export default compose(
// withConnect,
// )(App);