'use strict';

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

exports.__esModule = true;
exports.Alert = void 0;

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

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

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

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

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

var _react = _interopRequireDefault(require("react"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _Popup = require("./Popup");

var _Button = require("../Button");

var _DangerousHTML = require("../DangerousHTML");

var Alert =
/*#__PURE__*/
function (_React$Component) {
  (0, _inheritsLoose2.default)(Alert, _React$Component);

  function Alert(props, context) {
    var _this;

    _this = _React$Component.call(this, props, context) || this;
    _this.submitAction = _this.submitAction.bind((0, _assertThisInitialized2.default)(_this));
    return _this;
  }

  var _proto = Alert.prototype;

  _proto.submitAction = function submitAction() {
    _Popup.Popup.close();

    if (this.props.submitAction) {
      this.props.submitAction();
    }
  };

  _proto.render = function render() {
    var _this$props = this.props,
        buttonYesStyle = _this$props.buttonYesStyle,
        submitText = _this$props.submitText,
        submitAction = _this$props.submitAction,
        props = (0, _objectWithoutPropertiesLoose2.default)(_this$props, ["buttonYesStyle", "submitText", "submitAction"]);
    var buttons = [_react.default.createElement(_Button.Button, {
      testAutomationId: "buttonYes",
      key: "buttonYes",
      bsStyle: buttonYesStyle,
      onClick: this.submitAction
    }, _react.default.createElement(_DangerousHTML.DangerousHTML, null, submitText))];
    return _react.default.createElement(_Popup.Popup, (0, _extends2.default)({}, props, {
      bsSize: "sm",
      footer: buttons,
      onClose: this.submitAction
    }));
  };

  return Alert;
}(_react.default.Component);

exports.Alert = Alert;
(0, _defineProperty2.default)(Alert, "propTypes", {
  buttonYesStyle: _propTypes.default.string,
  submitAction: _propTypes.default.func,
  submitText: _propTypes.default.string,
  title: _propTypes.default.string,
  testAutomationId: _propTypes.default.string,
  shouldDeriveDescFromBody: _propTypes.default.bool
});
(0, _defineProperty2.default)(Alert, "defaultProps", {
  buttonYesStyle: 'primary',
  title: 'TRANSLATE:ALERT',
  submitText: 'TRANSLATE:OK',
  submitAction: null,
  testAutomationId: 'alert',
  shouldDeriveDescFromBody: true
});