MyCrypto/common/containers/App/index.jsx

92 lines
2.2 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
componentWillMount() {
2017-05-23 23:06:01 +00:00
let { handleWindowResize } = this.props;
window.addEventListener('resize', handleWindowResize);
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;
// let title = children.props.route.name;
2017-04-12 05:04:27 +00:00
let headerProps = {
changeLanguage,
languageSelection,
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-23 23:06:01 +00:00
{children}
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);