"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _reactRedux = require("react-redux");

var _record = require("../../actions/record");

var _RecordForm = _interopRequireDefault(require("../../components/record/RecordForm"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

const mapDispatchToProps = (dispatch, ownProps) => {
  const {
    config,
    csid,
    recordTypeConfig
  } = ownProps;
  return {
    onAddInstance: (path, position) => {
      dispatch((0, _record.addFieldInstance)(recordTypeConfig, csid, path, position));
    },
    onCommit: (path, value) => {
      dispatch((0, _record.setFieldValue)(recordTypeConfig, csid, path, value));
    },
    onMoveInstance: (path, newPosition) => {
      dispatch((0, _record.moveFieldValue)(recordTypeConfig, csid, path, newPosition));
    },
    onRemoveInstance: path => {
      dispatch((0, _record.deleteFieldValue)(recordTypeConfig, csid, path));
    },
    onSortInstances: (path, byField) => {
      dispatch((0, _record.sortFieldInstances)(config, recordTypeConfig, csid, path, byField));
    }
  };
};

var _default = (0, _reactRedux.connect)(undefined, mapDispatchToProps)(_RecordForm.default);

exports.default = _default;