import { Modal } from "antd";
import RREarlyROForm from "./rr-early-ro-form";

/**
 * Modal wrapper for RR Early RO Creation Form
 * @param open - boolean to control modal visibility
 * @param onClose - callback when modal is closed
 * @param onSuccess - callback when RO is created successfully
 * @param bodyshop - bodyshop object
 * @param socket - socket.io connection
 * @param job - job object
 * @returns {JSX.Element}
 * @constructor
 */
export default function RREarlyROModal({ open, onClose, onSuccess, bodyshop, socket, job }) {
  const handleSuccess = (result) => {
    onSuccess?.(result);
    onClose?.();
  };

  return (
    <Modal
      open={open}
      onCancel={onClose}
      footer={null}
      width={700}
      destroyOnHidden
      title="Create Reynolds Repair Order"
    >
      <RREarlyROForm bodyshop={bodyshop} socket={socket} job={job} onSuccess={handleSuccess} onCancel={onClose} />
    </Modal>
  );
}
