MyCrypto/common/containers/App/index.jsx

88 lines
2.2 KiB
React
Raw Normal View History

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