require("../../../../_virtual/_rolldown/runtime.js");
const require_useComponents = require("../../../../hooks/useComponents.js");
let react = require("react");
let antd = require("antd");
//#region src/components/schedules/resources/add/index.tsx
const ResourcesAdd = ({ onSuccess }, refs) => {
	const formDataNewRef = (0, react.useRef)();
	const [FormDataNew] = require_useComponents.default({ components: ["FormDataNew"] });
	const [open, setOpen] = (0, react.useState)(false);
	const [formId, setFormId] = (0, react.useState)(0);
	const onClose = () => {
		setOpen(false);
	};
	const onOpen = () => {
		setOpen(true);
	};
	(0, react.useImperativeHandle)(refs, () => {
		return { open: (form_id) => {
			onOpen();
			setFormId(form_id);
		} };
	});
	const onSubmit = () => {
		var _formDataNewRef$curre;
		(_formDataNewRef$curre = formDataNewRef.current) === null || _formDataNewRef$curre === void 0 || _formDataNewRef$curre.submit();
	};
	return /* @__PURE__ */ React.createElement(antd.Modal, {
		open,
		width: 700,
		onCancel: onClose,
		onOk: onSubmit,
		destroyOnClose: true
	}, FormDataNew && /* @__PURE__ */ React.createElement(FormDataNew, {
		formId,
		ref: formDataNewRef,
		formChange: (isSuccess, params) => {
			if (isSuccess) {
				onSuccess === null || onSuccess === void 0 || onSuccess(params);
				onClose();
			}
		}
	}));
};
var add_default = (0, react.forwardRef)(ResourcesAdd);
//#endregion
exports.default = add_default;
