import { forwardRef, Fragment, Ref, useEffect, useImperativeHandle, useState } from "react"; import { Dialog, DialogBackdrop, DialogPanel, Transition, TransitionChild } from "@headlessui/react"; import { useTranslation } from "react-i18next"; import clsx from "~/utils/shared/ClassesUtils"; import { AlertTriangleIcon } from "~/components/ui/icons/vendor"; export interface RefErrorModal { show: (title?: string, description?: string) => void; } interface Props { className?: string; onClosed?: () => void; } const ErrorModal = ({ className, onClosed }: Props, ref: Ref) => { const { t } = useTranslation(); const [open, setOpen] = useState(false); const [title, setTitle] = useState(); const [description, setDescription] = useState(); const [closeText, setCloseText] = useState(); useEffect(() => { setTitle(t("shared.error").toString()); setCloseText(t("shared.close")); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); function show(_title?: string, _description?: string) { if (_title) { setTitle(_title); } if (_description) { setDescription(_description); } else if (_title) { setTitle(t("shared.error").toString()); setDescription(_title); } setOpen(true); } useImperativeHandle(ref, () => ({ show })); function close() { setOpen(false); if (onClosed) { onClosed(); } } return (
{/* Subframe ResultDialog layout: flex-col items-center gap-6, rounded-lg, px-6 py-8, icon badge h-14 w-14 rounded-round, content gap-2, full-width button. */}

{title}

{description}

); }; export default forwardRef(ErrorModal);