import { connect } from 'react-redux';
import { StoreState } from 'store/rootReducer';

import blog from 'store/blog';
import Manage, { StateProps, DispatchProps, OwnProps } from './Manage';

const mapStateToProps = (state: StoreState): {} => ({
  detail: state.blog.detail,
});

const mapDispatchToProps = {
  addData: blog.actions.add.request.action,
  loadData: blog.actions.loadOne.request.action,
  editData: blog.actions.edit.request.action,
  searchData: blog.actions.search.request.action,
};

const Wrapped = connect<StateProps, DispatchProps, OwnProps>(
  mapStateToProps,
  mapDispatchToProps,
)(Manage);

export default Wrapped;
