import { useState, useEffect } from "react"; import { useTranslation } from "react-i18next"; import Markdown from "react-markdown"; import remarkGfm from "remark-gfm"; import { code } from "../markdown/code"; import { ol, ul } from "../markdown/list"; import ArrowUp from "#/icons/angle-up-solid.svg?react"; import ArrowDown from "#/icons/angle-down-solid.svg?react"; import CheckCircle from "#/icons/check-circle-solid.svg?react"; import XCircle from "#/icons/x-circle-solid.svg?react"; import { cn } from "#/utils/utils"; interface ExpandableMessageProps { id?: string; message: string; type: string; success?: boolean; } export function ExpandableMessage({ id, message, type, success, }: ExpandableMessageProps) { const { t, i18n } = useTranslation(); const [showDetails, setShowDetails] = useState(true); const [headline, setHeadline] = useState(""); const [details, setDetails] = useState(message); useEffect(() => { if (id && i18n.exists(id)) { setHeadline(t(id)); setDetails(message); setShowDetails(false); } }, [id, message, i18n.language]); const statusIconClasses = "h-4 w-4 ml-2 inline"; return (
{headline && (
{headline} {type === "action" && success !== undefined && ( {success ? ( ) : ( )} )}
)} {showDetails && ( {details} )}
); }