"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

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

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

var _antd = require("antd");

var _UIApiContext = _interopRequireDefault(require("../UIApiContext"));

var _ResultPanelModule = _interopRequireDefault(require("./ResultPanel.module.less"));

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

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

var _default = function _default(_ref) {
  var name = _ref.name,
      onFinish = _ref.onFinish;

  var _useContext = (0, _react.useContext)(_UIApiContext.default),
      api = _useContext.api;

  var intl = api.intl; // const [alive, setAlive] = useState<boolean>(false);
  // const isMini = api.isMini();
  // useEffect(() => {
  //   (async () => {
  //     const msg = (await api.callRemote({
  //       type: 'tasks/is_dev_server_alive',
  //     })) as {
  //       alive: boolean;
  //     };
  //     setAlive(msg.alive);
  //   })();
  // }, []);

  return /*#__PURE__*/_react.default.createElement("div", {
    className: _ResultPanelModule.default.result
  }, /*#__PURE__*/_react.default.createElement(_antd.Result, {
    status: "success",
    title: "".concat(name, " ").concat(intl({
      id: 'org.umi.ui.blocks.adder.result.success'
    })),
    subTitle: intl({
      id: 'org.umi.ui.blocks.adder.result.subTitle'
    }),
    extra: /*#__PURE__*/_react.default.createElement(_antd.Button, {
      type: "primary",
      key: "preview",
      onClick: function onClick() {
        return onFinish();
      }
    }, intl({
      id: 'org.umi.ui.blocks.adder.result.done'
    })) // isMini || !alive
    //   ? [
    //       <Button type="primary" key="preview" onClick={() => onFinish()}>
    //         {intl({ id: 'org.umi.ui.blocks.adder.result.done' })}
    //       </Button>,
    //     ]
    //   : [
    //       <Button
    //         type="primary"
    //         key="preview"
    //         onClick={() => {
    //           window.open(url);
    //           onFinish();
    //         }}
    //       >
    //         {intl({ id: 'org.umi.ui.blocks.adder.result.preview' })}
    //       </Button>,
    //     ]

  }));
};

exports.default = _default;