'use strict';

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

var _redux = require('redux');

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

var _alerts = require('../../../../../common/actions/alerts');

var alertActions = _interopRequireWildcard(_alerts);

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

var quizEntryApiActions = _interopRequireWildcard(_quizEntries);

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

var modalActions = _interopRequireWildcard(_modal);

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

var _stateHelper2 = _interopRequireDefault(_stateHelper);

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

var _presenter2 = _interopRequireDefault(_presenter);

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

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 mapStateToProps(state, props) {
  var dndPosition = state.getIn(['dragAndDrop', 'position']);
  var draggingAboveHalf = state.getIn(['dragAndDrop', 'aboveHalf'], false);
  var draggingOver = props.draggingOnBuild && dndPosition === props.quizEntry.position;
  return {
    draggingAboveHalf: draggingOver && draggingAboveHalf,
    draggingOver: draggingOver,
    quizEntryWithErrorsShowing: _stateHelper2.default.quizEntryWithErrorsShowing()
  };
} // TODO: move this


function mapDispatchToProps(dispatch) {
  var boundAlertActions = (0, _redux.bindActionCreators)(alertActions, dispatch);
  var boundApiActions = (0, _redux.bindActionCreators)(quizEntryApiActions, dispatch);
  var boundModalActions = (0, _redux.bindActionCreators)(modalActions, dispatch);

  return {
    removeQuizEntry: boundApiActions.removeQuizEntry,
    screenreaderNotification: boundAlertActions.screenreaderNotification,
    withConfirm: boundModalActions.withConfirm
  };
}

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