'use strict';

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

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

var _get = require('lodash/get');

var _get2 = _interopRequireDefault(_get);

var _VocabularyPage = require('../../components/pages/VocabularyPage');

var _VocabularyPage2 = _interopRequireDefault(_VocabularyPage);

var _prefs = require('../../actions/prefs');

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

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

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

const mapStateToProps = (state, ownProps) => {
  const match = ownProps.match;


  const csid = (0, _get2.default)(match, ['params', 'csid']);
  const data = csid && csid !== 'new' ? (0, _reducers.getRecordData)(state, csid) : undefined;

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

const mapDispatchToProps = {
  readVocabularyItemRefs: _vocabulary.readVocabularyItemRefs,
  setAdminTab: _prefs.setAdminTab
};

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