'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: '\u91CD\u555F\u905E\u4EA4\u6A5F\u6703',
        continueText: '\u91CD\u555F',
        text: '\u91CD\u555F\u6B64\u905E\u4EA4\u6A5F\u6703\u5C07\u5141\u8A31\u5B78\u751F\u7E7C\u7E8C\u9032\u884C\u6B64\u8A55\u4F30\u3002\n        \u4E4B\u524D\u6240\u8A18\u9304\u7684\u56DE\u61C9\u5C07\u7372\u4FDD\u7559\u3002\u5982\u679C\u6B64\u70BA\u5373\u6642\u8A55\u4F30\uFF0C\n        \u8A08\u6642\u5668\u6839\u64DA\u7B2C\u4E00\u6B21\u63D0\u4EA4\u6642\u5269\u9918\u7684\u6642\u9593\u7E7C\u7E8C\u8A08\u6642\u3002'
      });
    }, _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' },
          '\u7BA1\u7406\u76EE\u524D\u7684\u905E\u4EA4\u6A5F\u6703'
        ),
        this.props.reopenOn ? _react2.default.createElement(
          _Button2.default,
          { onClick: this.reopenQuizSession, disabled: !this.props.isComplete, margin: 'small' },
          '\u91CD\u555F'
        ) : 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;