MyCrypto/common/containers/App/index.jsx

86 lines
2.1 KiB
React
Raw Normal View History

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-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 = {
children: PropTypes.node.isRequired,
location: PropTypes.object,
handleWindowResize: PropTypes.func,
router: PropTypes.object,
isMobile: PropTypes.bool,
// BEGIN ACTUAL
2017-05-23 23:06:01 +00:00
languageSelection: PropTypes.object,
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,
// APP
languageSelection,
changeLanguage,
changeNode,
2017-05-23 23:06:01 +00:00
nodeSelection
} = 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,
changeLanguage,
languageSelection,
2017-06-18 19:47:00 +00:00
location,
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">
{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 {
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);