require("../../../../_virtual/_rolldown/runtime.js");
const require_asyncToGenerator = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
const require_serve = require("../serve.js");
let react = require("react");
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
//#region src/components/booking/forms/sendModal/useSendModal.ts
const useSendModal = (bookingId) => {
	const [open, setOpen] = (0, react.useState)(false);
	const handleOpen = () => {
		setOpen(true);
	};
	const handleValuesChange = (val) => {
		console.log(val, "val");
	};
	return {
		open,
		setOpen,
		handleOpen,
		handleValuesChange,
		handleOk: function() {
			var _ref = require_asyncToGenerator._asyncToGenerator(function* (values) {
				if (!values.sendSms && !values.sendEmail) return _pisell_materials.message.error(_pisell_utils.locales.getText("pisell2.text.send-form-reminder-error-message"));
				if (values.sendSms && !values.phone.phone) return _pisell_materials.message.error(_pisell_utils.locales.getText("pisell2.text.phone-required-error-message"));
				if (values.sendEmail && !values.email) return _pisell_materials.message.error(_pisell_utils.locales.getText("pisell2.text.email-required-error-message"));
				yield require_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
				});
				_pisell_materials.message.success(_pisell_utils.locales.getText("pisell2.text.send-form-toast"));
				setOpen(false);
			});
			return function handleOk(_x) {
				return _ref.apply(this, arguments);
			};
		}()
	};
};
//#endregion
exports.default = useSendModal;
