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