function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
import React from 'react';
import { Form, Checkbox, Input } from 'antd';
import { PisellModal } from '@pisell/materials';
import PhoneField from "../../../pisellSelectCustomerModal/RightPanel/Add/PhoneField";
import { locales } from '@pisell/utils';
import "./index.less";
var SendModal = function SendModal(_ref) {
  var open = _ref.open,
    refreshKey = _ref.refreshKey,
    onCancel = _ref.onCancel,
    onOk = _ref.onOk,
    _ref$defaultValues = _ref.defaultValues,
    defaultValues = _ref$defaultValues === void 0 ? {} : _ref$defaultValues,
    onValuesChange = _ref.onValuesChange;
  var _Form$useForm = Form.useForm(),
    _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
    form = _Form$useForm2[0];
  var sendSms = Form.useWatch('sendSms', form);
  var sendEmail = Form.useWatch('sendEmail', form);
  var handleOk = function handleOk() {
    form.validateFields().then(function (values) {
      onOk(values);
    });
  };
  return /*#__PURE__*/React.createElement(PisellModal, {
    open: open,
    title: locales.getText('pisell2.text.send-form-reminder'),
    onCancel: onCancel,
    onOk: handleOk,
    okText: locales.getText('pisell2.text.send-form-ok')
  }, /*#__PURE__*/React.createElement("div", {
    className: "pisell-lowcode-send-form-wrap"
  }, /*#__PURE__*/React.createElement(Form, {
    form: form,
    key: refreshKey,
    onValuesChange: onValuesChange,
    layout: "vertical",
    initialValues: defaultValues
  }, /*#__PURE__*/React.createElement(Form.Item, {
    name: "sendSms",
    valuePropName: "checked",
    style: {
      marginBottom: 12
    }
  }, /*#__PURE__*/React.createElement(Checkbox, null, locales.getText('pisell2.text.send-sms-reminder'))), /*#__PURE__*/React.createElement(Form.Item, {
    name: "phone",
    style: {
      marginLeft: 16
    },
    rules: [{
      required: sendSms,
      message: locales.getText('pisell2.text.phone-required-error-message')
    }]
  }, /*#__PURE__*/React.createElement(PhoneField, null)), /*#__PURE__*/React.createElement(Form.Item, {
    name: "sendEmail",
    valuePropName: "checked",
    style: {
      marginBottom: 12
    }
  }, /*#__PURE__*/React.createElement(Checkbox, null, locales.getText('pisell2.text.send-email-reminder'))), /*#__PURE__*/React.createElement(Form.Item, {
    name: "email",
    style: {
      marginLeft: 16
    },
    rules: [{
      required: sendEmail,
      message: locales.getText('pisell2.text.email-required-error-message')
    }, {
      pattern: /^([a-zA-Z0-9_\-\.+])+@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,63})+$/,
      message: locales.getText('pisell2.text.email-error-message')
    }]
  }, /*#__PURE__*/React.createElement(Input, {
    size: "large"
  })))));
};
export default SendModal;