import React from 'react';
import { connect } from "../../../redux";
import { Modal } from '@whalecloud/fdx';
import { i18n } from '@fishx/i18n';
import { ExclamationCircleOutlined } from '@fishx/icons';
import { IconButton } from '@webiny/ui/Button';
import { ReactComponent as InactiveIcon } from "@svgr/webpack!../../../assets/icons/delete.svg";

var PagePreviewButton = function PagePreviewButton(_ref) {
  var updateElement = _ref.updateElement;

  var handleClick = function handleClick() {
    updateElement({
      elements: {},
      page: {}
    });
  };

  var modalConfirms = function modalConfirms() {
    Modal.confirm({
      title: i18n('PAGEBUIDER_OPERATE_DELETE_TIPS'),
      icon: /*#__PURE__*/React.createElement(ExclamationCircleOutlined, null),
      content: i18n('PAGEBUIDER_OPERATE_DELETE_TIPS_CONTENT'),
      onOk: handleClick
    });
  };

  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
    className: "formbuild-btn-opt red",
    onClick: function onClick() {
      return modalConfirms();
    }
  }, /*#__PURE__*/React.createElement(IconButton, {
    icon: /*#__PURE__*/React.createElement(InactiveIcon, null)
  }), /*#__PURE__*/React.createElement("span", null, i18n('PAGEBUIDER_OPT_CLEAR'))));
};

var mapDispatchToProps = function mapDispatchToProps(dispatch) {
  return {
    updateElement: function updateElement(payload) {
      dispatch({
        type: 'appBuilder/save',
        payload: payload
      });
    }
  };
};

export default connect(null, mapDispatchToProps)(PagePreviewButton);
//# sourceMappingURL=PageClearButton.js.map