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

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

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

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

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

export default Wrapped;
