2017-05-24 22:39:58 +00:00
|
|
|
// @flow
|
2017-05-23 23:06:01 +00:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { Footer, Header } from 'components';
|
|
|
|
import PropTypes from 'prop-types';
|
2017-04-14 06:22:53 +00:00
|
|
|
|
2017-05-23 23:06:01 +00:00
|
|
|
import { CHANGE_LANGUAGE, CHANGE_NODE } from 'actions/config';
|
2017-04-12 05:04:27 +00:00
|
|
|
|
|
|
|
class App extends Component {
|
|
|
|
constructor(props) {
|
2017-05-23 23:06:01 +00:00
|
|
|
super(props);
|
2017-04-12 05:04:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static propTypes = {
|
2017-04-14 06:22:53 +00:00
|
|
|
children: PropTypes.node.isRequired,
|
|
|
|
location: PropTypes.object,
|
|
|
|
handleWindowResize: PropTypes.func,
|
2017-04-25 00:03:41 +00:00
|
|
|
|
2017-04-14 06:22:53 +00:00
|
|
|
router: PropTypes.object,
|
|
|
|
isMobile: PropTypes.bool,
|
|
|
|
|
|
|
|
// BEGIN ACTUAL
|
2017-05-23 23:06:01 +00:00
|
|
|
languageSelection: PropTypes.object,
|
2017-04-14 06:22:53 +00:00
|
|
|
changeLanguage: PropTypes.func,
|
|
|
|
|
|
|
|
changeNode: PropTypes.func,
|
2017-05-23 23:06:01 +00:00
|
|
|
nodeSelection: PropTypes.object
|
|
|
|
};
|
2017-04-12 05:04:27 +00:00
|
|
|
|
|
|
|
render() {
|
|
|
|
let {
|
|
|
|
children,
|
2017-04-25 00:03:41 +00:00
|
|
|
// APP
|
2017-04-14 06:22:53 +00:00
|
|
|
languageSelection,
|
|
|
|
changeLanguage,
|
|
|
|
changeNode,
|
2017-05-23 23:06:01 +00:00
|
|
|
nodeSelection
|
2017-04-14 06:22:53 +00:00
|
|
|
} = this.props;
|
2017-06-18 19:47:00 +00:00
|
|
|
|
2017-04-12 05:04:27 +00:00
|
|
|
let headerProps = {
|
2017-06-18 19:56:12 +00:00
|
|
|
location,
|
2017-04-14 06:22:53 +00:00
|
|
|
changeLanguage,
|
|
|
|
languageSelection,
|
2017-06-18 19:47:00 +00:00
|
|
|
location,
|
2017-04-14 06:22:53 +00:00
|
|
|
changeNode,
|
2017-05-23 23:06:01 +00:00
|
|
|
nodeSelection
|
|
|
|
};
|
2017-04-12 05:04:27 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="page-layout">
|
|
|
|
<main>
|
2017-05-23 23:06:01 +00:00
|
|
|
<Header {...headerProps} />
|
2017-04-12 05:04:27 +00:00
|
|
|
<div className="main-content">
|
2017-05-30 11:19:51 +00:00
|
|
|
{React.cloneElement(children, { languageSelection })}
|
2017-04-12 05:04:27 +00:00
|
|
|
</div>
|
2017-05-23 23:06:01 +00:00
|
|
|
<Footer />
|
2017-04-12 05:04:27 +00:00
|
|
|
</main>
|
|
|
|
|
|
|
|
</div>
|
2017-05-23 23:06:01 +00:00
|
|
|
);
|
2017-04-12 05:04:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function mapStateToProps(state) {
|
|
|
|
return {
|
2017-04-14 06:22:53 +00:00
|
|
|
nodeSelection: state.config.nodeSelection,
|
|
|
|
nodeToggle: state.config.nodeToggle,
|
|
|
|
languageSelection: state.config.languageSelection,
|
|
|
|
languageToggle: state.config.languageToggle
|
2017-05-23 23:06:01 +00:00
|
|
|
};
|
2017-04-12 05:04:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function mapDispatchToProps(dispatch) {
|
|
|
|
return {
|
2017-05-23 23:22:06 +00:00
|
|
|
// FIXME replace with actual types
|
|
|
|
changeNode: (i: any) => {
|
2017-05-23 23:06:01 +00:00
|
|
|
dispatch(CHANGE_NODE(i));
|
2017-04-12 05:04:27 +00:00
|
|
|
},
|
2017-05-23 23:22:06 +00:00
|
|
|
changeLanguage: (i: any) => {
|
2017-05-23 23:06:01 +00:00
|
|
|
dispatch(CHANGE_LANGUAGE(i));
|
2017-04-12 05:04:27 +00:00
|
|
|
}
|
2017-05-23 23:06:01 +00:00
|
|
|
};
|
2017-04-12 05:04:27 +00:00
|
|
|
}
|
|
|
|
|
2017-05-23 23:06:01 +00:00
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(App);
|