import { useEffect, useRef } from "preact/hooks"; import { t } from "../../services/i18n"; import { ComponentChildren } from "preact"; interface ModalProps { className: string; title: string; size: "lg" | "sm"; children: ComponentChildren; footer?: ComponentChildren; onShown?: () => void; } export default function Modal({ children, className, size, title, footer, onShown }: ModalProps) { const modalRef = useRef(null); if (onShown) { useEffect(() => { const modalElement = modalRef.current; if (modalElement) { modalElement.addEventListener("shown.bs.modal", onShown); } }); } return (
{title}
{children}
{footer && (
{footer}
)}
); }