reverse-proxy-frontend/src/components/App.js

60 lines
1.8 KiB
JavaScript
Raw Normal View History

2020-05-20 03:34:38 +03:00
import React, { Suspense, useEffect } from "react";
import PropTypes from "prop-types";
2020-04-14 10:53:19 +03:00
import { Route, Switch } from "react-router-dom";
import HomePage from "./home/HomePage";
2020-05-13 19:25:14 +03:00
import Header from "./layout/Header";
2020-04-14 10:53:19 +03:00
import PageNotFound from "./PageNotFound";
2020-05-12 02:31:25 +03:00
import SessionContainer from "../features/session/components/SessionContainer";
2020-05-14 15:29:32 +03:00
import ReleaseNotesContainer from "../features/releaseNotes/components/ReleaseNotesContainer";
2020-05-15 00:04:27 +03:00
import AboutContainer from "../features/about/components/AboutContainer";
2020-05-20 03:34:38 +03:00
import { connect } from "react-redux";
import { bindActionCreators } from "redux";
import { loadFrontendSession } from "../features/frontendSession/actionCreators";
2020-05-21 00:58:51 +03:00
import ToastNotifier from "../features/snackbar/components/ToastNotifier";
2020-06-06 01:42:11 +03:00
import BotsManager from "../features/chatbot/components/BotsManager";
2020-05-20 03:34:38 +03:00
function App({ actions }) {
useEffect(() => {
actions.loadFrontendSession();
}, []);
2020-05-13 22:51:15 +03:00
2020-05-13 23:45:16 +03:00
const contentStyle = {
2020-05-14 00:01:30 +03:00
paddingLeft: "30px",
paddingRight: "30px"
2020-05-13 23:45:16 +03:00
};
2020-05-13 22:51:15 +03:00
2020-04-14 10:53:19 +03:00
return (
2020-05-14 00:01:30 +03:00
<Suspense fallback={<div></div>}>
2020-04-14 10:53:19 +03:00
<Header />
2020-06-06 01:42:11 +03:00
<BotsManager />
2020-05-13 19:25:14 +03:00
<br />
2020-05-13 23:45:16 +03:00
<div style={contentStyle}>
2020-05-13 22:51:15 +03:00
<Switch>
<Route exact path="/" component={HomePage} />
2020-05-15 00:04:27 +03:00
<Route path="/about" component={AboutContainer} />
2020-05-13 22:51:15 +03:00
<Route path="/sessions" component={SessionContainer} />
2020-05-14 15:29:32 +03:00
<Route path="/release-notes" component={ReleaseNotesContainer} />
2020-05-13 22:51:15 +03:00
<Route component={PageNotFound} />
</Switch>
2020-05-21 00:58:51 +03:00
<ToastNotifier />
2020-05-13 23:45:16 +03:00
</div>
2020-05-14 00:01:30 +03:00
</Suspense>
2020-04-14 10:53:19 +03:00
);
}
2020-05-20 03:34:38 +03:00
App.propTypes = {
actions: PropTypes.object.isRequired
};
function mapStateToProps() {
return {};
}
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({ loadFrontendSession }, dispatch)
};
}
export default connect(mapStateToProps, mapDispatchToProps)(App);