import React, { ReactNode } from "react";
import Modal from "antd/es/modal/Modal";

type AppModalProps = {
  isOpen: boolean;
  title?: string;
  handleOk?: () => void;
  handleCancel?: () => void;
  children: ReactNode;
  okText?: string;
  cancelText?: string;
  width?: number | string;
  footer?: boolean;
  destroyOnClose?: boolean;
  maskClosable?: boolean;
};

const AppModal: React.FC<AppModalProps> = ({
  isOpen,
  title,
  handleOk,
  handleCancel,
  children,
  okText,
  cancelText,
  width,
  footer = false,
  destroyOnClose = true,
  maskClosable = false,
}) => {
  return (
    <Modal
      title={title}
      open={isOpen}
      onOk={handleOk}
      onCancel={handleCancel}
      okText={okText}
      cancelText={cancelText}
      width={width}
      footer={footer}
      maskClosable={maskClosable}
      destroyOnClose={destroyOnClose}
    >
      {children}
    </Modal>
  );
};

export default AppModal;
