import React from 'react';
import { Spin } from 'antd';
import { PisellModal, Tag } from '@pisell/materials';
import { formatToken } from "../../../../model";
import OnlineWarningAlert from "../../../../components/shared/OnlineWarningAlert";
import "./index.less";
var DeleteWorkAreaModal = function DeleteWorkAreaModal(_ref) {
  var open = _ref.open,
    loading = _ref.loading,
    submitting = _ref.submitting,
    record = _ref.record,
    counts = _ref.counts,
    translation = _ref.translation,
    getText = _ref.getText,
    onClose = _ref.onClose,
    onConfirm = _ref.onConfirm;
  var total = counts.smart + counts.dumb + counts.integrated;
  var hasDevices = total > 0;
  var workAreaName = translation(record === null || record === void 0 ? void 0 : record.name) || '';
  return /*#__PURE__*/React.createElement(PisellModal, {
    open: open,
    title: getText('pisell2.saas.device-planning.delete.title'),
    headerDivider: false,
    onCancel: onClose,
    okVisible: !hasDevices,
    okText: getText('pisell2.saas.device-planning.delete.confirm-button'),
    cancelText: getText(hasDevices ? 'pisell2.saas.device-planning.delete.close' : 'pisell2.saas.device-planning.delete.cancel'),
    okButtonProps: {
      block: true,
      size: 'large',
      danger: true,
      loading: submitting,
      onClick: onConfirm
    },
    cancelButtonProps: {
      block: true,
      size: 'large',
      type: 'default',
      disabled: submitting
    },
    destroyOnClose: true,
    maskClosable: false,
    width: 520,
    className: "saas-device-planning-delete-modal",
    bodyStyle: {
      padding: '0 24px 24px'
    },
    footer: loading ? null : undefined
  }, loading ? /*#__PURE__*/React.createElement("div", {
    className: "saas-device-planning-delete-modal__loading"
  }, /*#__PURE__*/React.createElement(Spin, null)) : hasDevices ? /*#__PURE__*/React.createElement("div", {
    className: "saas-device-planning-delete-modal__body"
  }, /*#__PURE__*/React.createElement(OnlineWarningAlert, {
    message: getText('pisell2.saas.device-planning.delete.block-title'),
    description: formatToken(getText('pisell2.saas.device-planning.delete.block-content'), {
      WorkAreaName: workAreaName
    })
  }), /*#__PURE__*/React.createElement("div", {
    className: "saas-device-planning-delete-modal__label"
  }, getText('pisell2.saas.device-planning.delete.devices-label')), /*#__PURE__*/React.createElement("div", {
    className: "saas-device-planning-delete-modal__counts"
  }, counts.smart > 0 ? /*#__PURE__*/React.createElement(Tag, null, formatToken(getText('pisell2.saas.device-planning.delete.smart-count'), {
    N: counts.smart
  })) : null, counts.dumb > 0 ? /*#__PURE__*/React.createElement(Tag, null, formatToken(getText('pisell2.saas.device-planning.delete.dumb-count'), {
    N: counts.dumb
  })) : null, counts.integrated > 0 ? /*#__PURE__*/React.createElement(Tag, null, formatToken(getText('pisell2.saas.device-planning.delete.integrated-count'), {
    N: counts.integrated
  })) : null)) : /*#__PURE__*/React.createElement("div", {
    className: "saas-device-planning-delete-modal__confirm"
  }, formatToken(getText('pisell2.saas.device-planning.delete.confirm'), {
    WorkAreaName: workAreaName
  })));
};
export default DeleteWorkAreaModal;