'use strict';

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

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

var _SearchResultTraverser = require('../../components/search/SearchResultTraverser');

var _SearchResultTraverser2 = _interopRequireDefault(_SearchResultTraverser);

var _searchHelpers = require('../../helpers/searchHelpers');

var _search = require('../../actions/search');

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

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

var mapStateToProps = function mapStateToProps(state, ownProps) {
  var searchName = ownProps.searchName,
      searchDescriptor = ownProps.searchDescriptor;


  var nextPageSearchDescriptor = (0, _searchHelpers.getNextPageSearchDescriptor)(searchDescriptor);
  var prevPageSearchDescriptor = (0, _searchHelpers.getPreviousPageSearchDescriptor)(searchDescriptor);

  return {
    nextPageSearchDescriptor: nextPageSearchDescriptor,
    prevPageSearchDescriptor: prevPageSearchDescriptor,
    searchState: (0, _reducers.getSearchState)(state, searchName, searchDescriptor),
    nextPageSearchState: (0, _reducers.getSearchState)(state, searchName, nextPageSearchDescriptor),
    prevPageSearchState: prevPageSearchDescriptor ? (0, _reducers.getSearchState)(state, searchName, prevPageSearchDescriptor) : undefined
  };
};

var mapDispatchToProps = {
  search: _search.search
};

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