import { connect } from 'react-redux';
import Component from './component';
import { removeUndo } from './actions';

const mapStateToProps = ({ undos: undosReducer }) => {
  const { undos } = undosReducer;

  return {
    undos,
  };
};

const mergeProps = (state, { dispatch }) => {
  return {
    ...state,

    onRemove({ id }) {
      dispatch(removeUndo({ id }));
    },
    onUndo({ undoCall, params }) {
      dispatch(undoCall({ ...params }));
    },
  };
};

export default connect(mapStateToProps, undefined, mergeProps)(Component);
