'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

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

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

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

var _SubrecordEditor = require('../../components/record/SubrecordEditor');

var _SubrecordEditor2 = _interopRequireDefault(_SubrecordEditor);

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

var mapStateToProps = function mapStateToProps(state, ownProps) {
  var containerCsid = ownProps.containerCsid,
      name = ownProps.name;


  var subrecordCsid = (0, _reducers.getRecordSubrecordCsid)(state, containerCsid, name);

  return {
    csid: subrecordCsid,
    data: (0, _reducers.getRecordData)(state, subrecordCsid),
    perms: (0, _reducers.getUserPerms)(state)
  };
};

var mapDispatchToProps = {
  detachSubrecord: _record.detachSubrecord
};

exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(_SubrecordEditor2.default);