'use strict';

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

var _redux = require('redux');

var _partial = require('lodash/partial');

var _partial2 = _interopRequireDefault(_partial);

var _reactRedux = require('../../../../../common/react-redux');

var _stateHelper = require('../../../../../common/util/stateHelper');

var _stateHelper2 = _interopRequireDefault(_stateHelper);

var _modal = require('../../../../../common/actions/modal');

var modalActions = _interopRequireWildcard(_modal);

var _ui = require('../../../../../common/actions/ui');

var _constants = require('../../../../../constants');

var _ImportModal = require('../../../../../common/components/ImportModal');

var _presenter = require('./presenter');

var _presenter2 = _interopRequireDefault(_presenter);

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

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

function mapStateToProps(state, props) {
  return {
    canImport: _stateHelper2.default.activeQuiz().canImport(),
    returnToUrl: props.returnToUrl
  };
}

var mapDispatchToProps = function mapDispatchToProps(dispatch) {
  return {
    openBanksTray: (0, _redux.bindActionCreators)(_ui.set.bind(void 0, _constants.BUILD_TRAY_OPEN, true), dispatch),
    setBanksTrayButtonRef: (0, _redux.bindActionCreators)((0, _partial2.default)(_ui.set, _constants.BUILD_TRAY_BUTTON_REF), dispatch),
    openModal: (0, _redux.bindActionCreators)(modalActions.openModal.bind(modalActions, (0, _ImportModal.generateImportModalId)('qtiImport')), dispatch)
  };
};

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