'use strict';

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

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

var _reactRouter = require('react-router');

var _KeywordSearchForm = require('../../components/search/KeywordSearchForm');

var _KeywordSearchForm2 = _interopRequireDefault(_KeywordSearchForm);

var _keywordSearch = require('../../actions/keywordSearch');

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

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

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

var mapStateToProps = function mapStateToProps(state) {
  return {
    keywordValue: (0, _reducers.getKeywordSearchKeyword)(state),
    recordTypeValue: (0, _reducers.getKeywordSearchRecordType)(state),
    vocabularyValue: (0, _reducers.getKeywordSearchVocabulary)(state)
  };
};

var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {
  return {
    onKeywordCommit: function onKeywordCommit(value) {
      dispatch((0, _keywordSearch.setKeywordSearchKeyword)(value));
    },
    onRecordTypeCommit: function onRecordTypeCommit(value) {
      dispatch((0, _prefs.setKeywordSearchRecordType)(value));
    },
    onVocabularyCommit: function onVocabularyCommit(value) {
      dispatch((0, _prefs.setKeywordSearchVocabulary)(value));
    },
    onSearch: function onSearch() {
      dispatch((0, _keywordSearch.initiateSearch)(ownProps.router.push));
    }
  };
};

var ConnectedKeywordSearchForm = exports.ConnectedKeywordSearchForm = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(_KeywordSearchForm2.default);

exports.default = (0, _reactRouter.withRouter)(ConnectedKeywordSearchForm);