import { ReactNode } from "react";

type ModalProps = {
  isOpen: boolean;
  title: string;
  children: ReactNode;
  onClose: () => void;
};

export default function Modal({ isOpen, title, children, onClose }: ModalProps) {
  if (!isOpen) return null;
  return (
    <div className="modal d-block" style={{ background: "rgba(0,0,0,0.4)" }} role="dialog">
      <div className="modal-dialog modal-dialog-centered">
        <div className="modal-content">
          <div className="modal-header">
            <h5 className="modal-title">{title}</h5>
            <button className="btn-close" onClick={onClose} aria-label="close" />
          </div>
          <div className="modal-body">{children}</div>
        </div>
      </div>
    </div>
  );
}
