'use strict';

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

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

var _vocabulary = require('../../actions/vocabulary');

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

var _StructuredDateInput = require('../../components/record/StructuredDateInput');

var _StructuredDateInput2 = _interopRequireDefault(_StructuredDateInput);

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

var mapStateToProps = function mapStateToProps(state) {
  var optionLists = {};
  var terms = {};

  _StructuredDateInput.optionListNames.forEach(function (optionListName) {
    optionLists[optionListName] = (0, _reducers.getOptionList)(state, optionListName);
  });

  _StructuredDateInput.vocabNames.forEach(function (vocabName) {
    var vocab = (0, _reducers.getVocabulary)(state, vocabName);

    terms[vocabName] = vocab ? vocab.items : null;
  });

  return {
    optionLists: optionLists,
    terms: terms,
    perms: (0, _reducers.getUserPerms)(state)
  };
};

var mapDispatchToProps = {
  readTerms: _vocabulary.readVocabularyItems
};

var ConnectedStructuredDateInput = exports.ConnectedStructuredDateInput = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(_StructuredDateInput2.default);

ConnectedStructuredDateInput.propTypes = _StructuredDateInput2.default.propTypes;

exports.default = ConnectedStructuredDateInput;