2019-01-03 17:14:25 +03:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { bindActionCreators } from 'redux';
|
|
|
|
import { Container, Notification } from 'devui';
|
|
|
|
import { clearNotification } from '../actions';
|
|
|
|
import Header from '../components/Header';
|
|
|
|
import Actions from '../containers/Actions';
|
|
|
|
import Settings from '../components/Settings';
|
|
|
|
|
|
|
|
class App extends Component {
|
|
|
|
render() {
|
|
|
|
const { section, theme, notification } = this.props;
|
|
|
|
let body;
|
|
|
|
switch (section) {
|
2019-01-10 21:51:14 +03:00
|
|
|
case 'Settings':
|
|
|
|
body = <Settings />;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
body = <Actions />;
|
2019-01-03 17:14:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Container themeData={theme}>
|
|
|
|
<Header section={section} />
|
|
|
|
{body}
|
2019-01-10 21:51:14 +03:00
|
|
|
{notification && (
|
|
|
|
<Notification
|
|
|
|
type={notification.type}
|
|
|
|
onClose={this.props.clearNotification}
|
|
|
|
>
|
2019-01-03 17:14:25 +03:00
|
|
|
{notification.message}
|
|
|
|
</Notification>
|
2019-01-10 21:51:14 +03:00
|
|
|
)}
|
2019-01-03 17:14:25 +03:00
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
App.propTypes = {
|
|
|
|
section: PropTypes.string.isRequired,
|
|
|
|
theme: PropTypes.object.isRequired,
|
|
|
|
notification: PropTypes.shape({
|
|
|
|
message: PropTypes.string,
|
2020-08-08 23:26:39 +03:00
|
|
|
type: PropTypes.string,
|
2019-01-03 17:14:25 +03:00
|
|
|
}),
|
2020-08-08 23:26:39 +03:00
|
|
|
clearNotification: PropTypes.func,
|
2019-01-03 17:14:25 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
function mapStateToProps(state) {
|
|
|
|
return {
|
|
|
|
section: state.section,
|
|
|
|
theme: state.theme,
|
2020-08-08 23:26:39 +03:00
|
|
|
notification: state.notification,
|
2019-01-03 17:14:25 +03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function mapDispatchToProps(dispatch) {
|
|
|
|
return {
|
2020-08-08 23:26:39 +03:00
|
|
|
clearNotification: bindActionCreators(clearNotification, dispatch),
|
2019-01-03 17:14:25 +03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-08-05 16:12:31 +03:00
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(App);
|