'use strict';

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

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

var _notification = require('../../actions/notification');

var _relation = require('../../actions/relation');

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

var _RelationEditor = require('../../components/record/RelationEditor');

var _RelationEditor2 = _interopRequireDefault(_RelationEditor);

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

var mapStateToProps = function mapStateToProps(state, ownProps) {
  var subject = ownProps.subject,
      object = ownProps.object,
      predicate = ownProps.predicate;


  return {
    objectData: (0, _reducers.getRecordData)(state, object.csid),
    objectError: (0, _reducers.getRecordError)(state, object.csid),
    findResult: (0, _reducers.getRelationFindResult)(state, subject, object, predicate),
    openModalName: (0, _reducers.getOpenModalName)(state)
  };
};

var mapDispatchToProps = {
  closeModal: _notification.closeModal,
  openModal: _notification.openModal,
  createRelation: _relation.createBidirectional,
  findRelation: _relation.find,
  unrelate: _relation.unrelateBidirectional,
  onUnmount: _relation.clearState
};

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