"use strict";

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

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

var _get = _interopRequireDefault(require("lodash/get"));

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

var _search = require("../../actions/search");

var _reducers = require("../../reducers");

var _InvocationModal = _interopRequireDefault(require("../../components/invocable/InvocationModal"));

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

const mapStateToProps = (state, ownProps) => {
  const {
    csid
  } = ownProps;
  return {
    data: (0, _reducers.getRecordData)(state, csid)
  };
};

const mapDispatchToProps = (dispatch, ownProps) => {
  const {
    config,
    csid,
    recordType
  } = ownProps;
  const recordTypeConfig = (0, _get.default)(config, ['recordTypes', recordType]);
  return {
    readRecord: () => dispatch((0, _record.readRecord)(config, recordTypeConfig, undefined, csid)),
    searchCsid: function searchCsid() {
      return dispatch((0, _search.searchCsid)(...arguments));
    }
  };
};

var _default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(_InvocationModal.default);

exports.default = _default;