2018-12-22 17:20:04 +03:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { bindActionCreators } from 'redux';
|
|
|
|
import Header from '../components/Header';
|
|
|
|
import MainSection from '../components/MainSection';
|
|
|
|
import * as TodoActions from '../actions/TodoActions';
|
|
|
|
|
|
|
|
const TodoApp = ({ todos, actions }) => (
|
|
|
|
<div>
|
|
|
|
<Header addTodo={actions.addTodo} />
|
|
|
|
<MainSection todos={todos} actions={actions} />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
|
|
|
TodoApp.propTypes = {
|
|
|
|
todos: PropTypes.array.isRequired,
|
2020-08-08 23:26:39 +03:00
|
|
|
actions: PropTypes.object.isRequired,
|
2018-12-22 17:20:04 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
function mapState(state) {
|
|
|
|
return {
|
2020-08-08 23:26:39 +03:00
|
|
|
todos: state.todos,
|
2018-12-22 17:20:04 +03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function mapDispatch(dispatch) {
|
|
|
|
return {
|
2020-08-08 23:26:39 +03:00
|
|
|
actions: bindActionCreators(TodoActions, dispatch),
|
2018-12-22 17:20:04 +03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-08-05 16:12:31 +03:00
|
|
|
export default connect(mapState, mapDispatch)(TodoApp);
|