"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

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

var _redux = require("redux");

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

var alertActions = _interopRequireWildcard(require("../../../../../common/actions/alerts"));

var quizEntryApiActions = _interopRequireWildcard(require("../../../../api/quizEntries"));

var modalActions = _interopRequireWildcard(require("../../../../../common/actions/modal"));

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

var _presenter = _interopRequireDefault(require("./presenter"));

// TODO: move this
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: _stateHelper.default.quizEntryWithErrorsShowing()
  };
}

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
  };
}

var _default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(_presenter.default);

exports.default = _default;