'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 _formatMessage = require('format-message');

var _formatMessage2 = _interopRequireDefault(_formatMessage);

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

var _Button2 = _interopRequireDefault(_Button);

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

var _Heading2 = _interopRequireDefault(_Heading);

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

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

  function ResetQuiz() {
    var _ref;

    var _temp, _this, _ret;

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

    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 = ResetQuiz.__proto__ || Object.getPrototypeOf(ResetQuiz)).call.apply(_ref, [this].concat(args))), _this), _this.reopenQuizSession = function () {
      _this.props.withConfirm(function () {
        return _this.props.reopenQuizSession(_this.props.sessionId);
      }, {
        title: 'Reopen attempt',
        continueText: 'Reopen',
        text: 'Reopening this attempt will allow the student to resume this assessment. \n        Previously recorded responses will be retained. If this was a timed assessment,\n        the timer will resume with any remaining time from the initial submission.'
      });
    }, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
  }

  (0, _createClass3.default)(ResetQuiz, [{
    key: 'render',
    value: function render() {
      if (!this.props.reopenOn) return null;
      if (!this.props.sessionId) return null;

      return _react2.default.createElement(
        'div',
        null,
        _react2.default.createElement(
          _Heading2.default,
          { level: 'h3' },
          'Manage current attempt'
        ),
        this.props.reopenOn ? _react2.default.createElement(
          _Button2.default,
          { onClick: this.reopenQuizSession, disabled: !this.props.isComplete, margin: 'small' },
          'Reopen'
        ) : null
      );
    }
  }]);
  ResetQuiz.displayName = 'ResetQuiz'
  ;
  return ResetQuiz;
}(_react.Component), _class.propTypes = {
  sessionId: _react.PropTypes.string.isRequired,
  isComplete: _react.PropTypes.bool.isRequired,
  reopenQuizSession: _react.PropTypes.func.isRequired,
  reopenOn: _react.PropTypes.bool.isRequired,
  withConfirm: _react.PropTypes.func.isRequired
}, _temp2);
exports.default = ResetQuiz;