2019-08-31 04:07:25 +05:00
|
|
|
import { bindActionCreators } from 'redux';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
|
|
|
import { makeCardIdsByListIdSelector, makeListByIdSelector } from '../selectors';
|
|
|
|
import { createCard, deleteList, updateList } from '../actions/entry';
|
|
|
|
import List from '../components/List';
|
|
|
|
|
|
|
|
const makeMapStateToProps = () => {
|
|
|
|
const listByIdSelector = makeListByIdSelector();
|
|
|
|
const cardIdsByListIdSelector = makeCardIdsByListIdSelector();
|
|
|
|
|
|
|
|
return (state, { id, index }) => {
|
|
|
|
const { name, isPersisted } = listByIdSelector(state, id);
|
|
|
|
const cardIds = cardIdsByListIdSelector(state, id);
|
|
|
|
|
|
|
|
return {
|
|
|
|
id,
|
|
|
|
index,
|
|
|
|
name,
|
|
|
|
isPersisted,
|
|
|
|
cardIds,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-02-03 18:42:31 +05:00
|
|
|
const mapDispatchToProps = (dispatch, { id }) =>
|
|
|
|
bindActionCreators(
|
|
|
|
{
|
2020-03-25 00:15:47 +05:00
|
|
|
onUpdate: (data) => updateList(id, data),
|
2020-02-03 18:42:31 +05:00
|
|
|
onDelete: () => deleteList(id),
|
2020-03-25 00:15:47 +05:00
|
|
|
onCardCreate: (data) => createCard(id, data),
|
2020-02-03 18:42:31 +05:00
|
|
|
},
|
|
|
|
dispatch,
|
|
|
|
);
|
2019-08-31 04:07:25 +05:00
|
|
|
|
2020-02-03 18:42:31 +05:00
|
|
|
export default connect(makeMapStateToProps, mapDispatchToProps)(List);
|