var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/booking/forms/sendModal/useSendModal.ts
var useSendModal_exports = {};
__export(useSendModal_exports, {
  default: () => useSendModal_default
});
module.exports = __toCommonJS(useSendModal_exports);
var import_react = require("react");
var import_materials = require("@pisell/materials");
var import_utils = require("@pisell/utils");
var import_serve = require("../serve");
var useSendModal = (bookingId) => {
  const [open, setOpen] = (0, import_react.useState)(false);
  const handleOpen = () => {
    setOpen(true);
  };
  const handleValuesChange = (val) => {
    console.log(val, "val");
  };
  const handleOk = async (values) => {
    if (!values.sendSms && !values.sendEmail) {
      return import_materials.message.error(
        import_utils.locales.getText("pisell2.text.send-form-reminder-error-message")
      );
    }
    if (values.sendSms && !values.phone.phone) {
      return import_materials.message.error(
        import_utils.locales.getText("pisell2.text.phone-required-error-message")
      );
    }
    if (values.sendEmail && !values.email) {
      return import_materials.message.error(
        import_utils.locales.getText("pisell2.text.email-required-error-message")
      );
    }
    const value = await (0, import_serve.sendFormReminder)({
      phone: values.sendSms ? values.phone.phone : void 0,
      email: values.sendEmail ? values.email : void 0,
      order_id: bookingId,
      country_calling_code: values.sendSms ? values.phone.code.replace("+", "") : void 0
    });
    import_materials.message.success(import_utils.locales.getText("pisell2.text.send-form-toast"));
    setOpen(false);
  };
  return {
    open,
    setOpen,
    handleOpen,
    handleValuesChange,
    handleOk
  };
};
var useSendModal_default = useSendModal;
