'use strict';

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

var _immutable = require('immutable');

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

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

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

var _QuizEntry = require('../../../../common/records/QuizEntry');

var _QuizEntry2 = _interopRequireDefault(_QuizEntry);

var _quizEntries = require('../../../api/quizEntries');

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

var _presenter2 = _interopRequireDefault(_presenter);

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

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

function mapStateToProps(state, props) {
  var _state$getIn$toObject = state.getIn(['ui', _constants.MOVE_IMMUTABLE_DATA], (0, _immutable.Map)()).toObject(),
      movedInSidebar = _state$getIn$toObject.movedInSidebar,
      quizId = _state$getIn$toObject.quizId,
      position = _state$getIn$toObject.position,
      stimulusQuizEntryId = _state$getIn$toObject.stimulusQuizEntryId,
      quizEntryId = _state$getIn$toObject.quizEntryId;

  var quizEntry = _QuizEntry2.default.create(state.getIn(['quizEntries', quizEntryId]));

  return {
    modalOpen: state.getIn(['modal', 'isOpen']) === _constants.MOVE_IMMUTABLE_MODAL,
    movedInSidebar: movedInSidebar,
    quizId: quizId,
    position: position,
    stimulusQuizEntryId: stimulusQuizEntryId,
    quizEntry: quizEntry
  };
}

var mapDispatchToProps = {
  closeModal: _modal.closeModal,
  moveImmutableQuizEntry: _quizEntries.moveImmutableQuizEntry,
  setUI: _ui.set
};

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