2019-01-03 17:14:25 +03:00
|
|
|
import React, { Component } from 'react';
|
2020-10-26 02:32:04 +03:00
|
|
|
import { connect, ResolveThunks } from 'react-redux';
|
2021-09-18 17:00:58 +03:00
|
|
|
import { Container, Notification } from '@redux-devtools/ui';
|
2019-01-03 17:14:25 +03:00
|
|
|
import { clearNotification } from '../actions';
|
|
|
|
import Header from '../components/Header';
|
|
|
|
import Actions from '../containers/Actions';
|
|
|
|
import Settings from '../components/Settings';
|
2020-10-26 02:32:04 +03:00
|
|
|
import { StoreState } from '../reducers';
|
2019-01-03 17:14:25 +03:00
|
|
|
|
2020-10-26 02:32:04 +03:00
|
|
|
type StateProps = ReturnType<typeof mapStateToProps>;
|
|
|
|
type DispatchProps = ResolveThunks<typeof actionCreators>;
|
|
|
|
type Props = StateProps & DispatchProps;
|
|
|
|
|
|
|
|
class App extends Component<Props> {
|
2019-01-03 17:14:25 +03:00
|
|
|
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>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-26 02:32:04 +03:00
|
|
|
const mapStateToProps = (state: StoreState) => ({
|
|
|
|
section: state.section,
|
|
|
|
theme: state.theme,
|
|
|
|
notification: state.notification,
|
|
|
|
});
|
2019-01-03 17:14:25 +03:00
|
|
|
|
2020-10-26 02:32:04 +03:00
|
|
|
const actionCreators = {
|
|
|
|
clearNotification,
|
|
|
|
};
|
2019-01-03 17:14:25 +03:00
|
|
|
|
2020-10-26 02:32:04 +03:00
|
|
|
export default connect(mapStateToProps, actionCreators)(App);
|