'use strict';

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

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _class, _temp2;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _reactImmutableProptypes = require('react-immutable-proptypes');

var _reactImmutableProptypes2 = _interopRequireDefault(_reactImmutableProptypes);

var _Button = require('@instructure/ui-buttons/lib/components/Button');

var _Button2 = _interopRequireDefault(_Button);

var _CloseButton = require('@instructure/ui-buttons/lib/components/CloseButton');

var _CloseButton2 = _interopRequireDefault(_CloseButton);

var _Heading = require('@instructure/ui-elements/lib/components/Heading');

var _Heading2 = _interopRequireDefault(_Heading);

var _Text = require('@instructure/ui-elements/lib/components/Text');

var _Text2 = _interopRequireDefault(_Text);

var _formatMessage = require('../../../../common/format-message');

var _formatMessage2 = _interopRequireDefault(_formatMessage);

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

var _Modal = require('../../../../common/components/Modal');

var _Modal2 = _interopRequireDefault(_Modal);

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

var MoveImmutableModal = (_temp2 = _class = function (_Component) {
  (0, _inherits3.default)(MoveImmutableModal, _Component);

  function MoveImmutableModal() {
    var _ref;

    var _temp, _this, _ret;

    (0, _classCallCheck3.default)(this, MoveImmutableModal);

    for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, (_ref = MoveImmutableModal.__proto__ || Object.getPrototypeOf(MoveImmutableModal)).call.apply(_ref, [this].concat(args))), _this), _this.handleSubmit = function (e) {
      var _this$props = _this.props,
          quizId = _this$props.quizId,
          position = _this$props.position,
          stimulusQuizEntryId = _this$props.stimulusQuizEntryId,
          quizEntry = _this$props.quizEntry;

      _this.props.closeModal();
      _this.props.setUI(_constants.MOVED_IN_SIDEBAR, _this.props.movedInSidebar);
      _this.props.moveImmutableQuizEntry(quizId, position, stimulusQuizEntryId, quizEntry.id);
    }, _this.closeAction = function () {
      _this.props.closeModal();
    }, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
  }

  (0, _createClass3.default)(MoveImmutableModal, [{
    key: 'cancelButton',
    value: function cancelButton() {
      return _react2.default.createElement(
        _Button2.default,
        { onClick: this.closeAction, margin: _constants.XSMALL_SIDE_MARGIN },
        'Annuleren'
      );
    }
  }, {
    key: 'doneButton',
    value: function doneButton() {
      return _react2.default.createElement(
        _Button2.default,
        {
          variant: 'primary',
          onClick: this.handleSubmit,
          margin: _constants.XSMALL_SIDE_MARGIN
        },
        'Klonen en verplaatsen'
      );
    }
  }, {
    key: 'renderBody',
    value: function renderBody() {
      return _react2.default.createElement(
        'div',
        null,
        'Door deze verplaatsing wordt de vraag gekloond en wordt de daaraan gekoppelde stimulus gewijzigd wanneer cursisten al aan het beantwoorden van de vraag zijn begonnen.'
      );
    }
  }, {
    key: 'render',
    value: function render() {
      return _react2.default.createElement(
        _Modal2.default,
        {
          open: this.props.modalOpen,
          onDismiss: this.closeAction,
          size: 'small',
          label: 'Klonen en verplaatsen bevestigen'
        },
        _react2.default.createElement(
          _Modal.ModalHeader,
          null,
          _react2.default.createElement(
            _Heading2.default,
            { level: 'reset', as: 'h2' },
            'Klonen en verplaatsen bevestigen'
          ),
          _react2.default.createElement(_CloseButton2.default, {
            onClick: this.closeAction,
            placement: 'end',
            offset: 'medium',
            variant: 'icon'
          })
        ),
        _react2.default.createElement(
          _Modal.ModalBody,
          null,
          _react2.default.createElement(
            _Text2.default,
            null,
            this.renderBody()
          )
        ),
        _react2.default.createElement(
          _Modal.ModalFooter,
          null,
          this.cancelButton(),
          this.doneButton()
        )
      );
    }
  }]);
  MoveImmutableModal.displayName = 'MoveImmutableModal'
  ;
  return MoveImmutableModal;
}(_react.Component), _class.propTypes = {
  closeModal: _propTypes2.default.func.isRequired,
  modalOpen: _propTypes2.default.bool.isRequired,
  moveImmutableQuizEntry: _propTypes2.default.func.isRequired,
  movedInSidebar: _propTypes2.default.bool,
  position: _propTypes2.default.number,
  quizEntry: _reactImmutableProptypes2.default.record,
  quizId: _propTypes2.default.string,
  setUI: _propTypes2.default.func.isRequired,
  stimulusQuizEntryId: _propTypes2.default.string
}, _class.defaultProps = {
  movedInSidebar: false,
  position: void 0,
  quizEntry: void 0,
  quizId: void 0,
  stimulusQuizEntryId: void 0
}, _temp2);
exports.default = MoveImmutableModal;