'use strict';

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

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

var _QuickSearchForm = require('../../components/search/QuickSearchForm');

var _QuickSearchForm2 = _interopRequireDefault(_QuickSearchForm);

var _quickSearch = require('../../actions/quickSearch');

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

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

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

const mapStateToProps = state => {
  const quickSearchRecordType = (0, _reducers.getQuickSearchRecordType)(state);

  return {
    keywordValue: (0, _reducers.getQuickSearchKeyword)(state),
    recordTypeValue: quickSearchRecordType,
    vocabularyValue: (0, _reducers.getQuickSearchVocabulary)(state, quickSearchRecordType),
    getAuthorityVocabCsid: (recordType, vocabulary) => (0, _reducers.getAuthorityVocabCsid)(state, recordType, vocabulary)
  };
};

const mapDispatchToProps = (dispatch, ownProps) => ({
  onKeywordCommit: value => {
    dispatch((0, _quickSearch.setQuickSearchKeyword)(value));
  },
  onRecordTypeCommit: value => {
    dispatch((0, _prefs.setQuickSearchRecordType)(value));
  },
  onVocabularyCommit: value => {
    dispatch((0, _prefs.setQuickSearchVocabulary)(value));
  },
  search: () => {
    dispatch((0, _quickSearch.initiateSearch)(ownProps.history.push));
  }
});

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