import useComponents from "../../../../hooks/useComponents.js";
import { forwardRef, useImperativeHandle, useRef, useState } from "react";
import { Modal } from "antd";
//#region src/components/schedules/resources/add/index.tsx
const ResourcesAdd = ({ onSuccess }, refs) => {
	const formDataNewRef = useRef();
	const [FormDataNew] = useComponents({ components: ["FormDataNew"] });
	const [open, setOpen] = useState(false);
	const [formId, setFormId] = useState(0);
	const onClose = () => {
		setOpen(false);
	};
	const onOpen = () => {
		setOpen(true);
	};
	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(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 = forwardRef(ResourcesAdd);
//#endregion
export { add_default as default };
