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

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

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

const mapDispatchToProps = {
  createForm: forms.actions.add.request.action,
  updateForm: forms.actions.update.request.action,
  getDetail: forms.actions.detailFormData.request.action,
};

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

export default Wrapped;
