import { useRef, useState } from 'react' import { ThreadMessage } from '@janhq/core' import { CheckIcon, ClipboardIcon, SearchCodeIcon } from 'lucide-react' const ErrorMessage = ({ message }: { message?: ThreadMessage }) => { // const setModalTroubleShooting = useSetAtom(modalTroubleShootingAtom) const errorDivRef = useRef(null) const [copied, setCopied] = useState(false) const handleCopy = () => { if (errorDivRef.current) { const errorText = errorDivRef.current.innerText if (errorText) { navigator.clipboard.writeText(errorText) setCopied(true) setTimeout(() => setCopied(false), 2000) } } } const getErrorTitle = () => { return (

<> {message?.content[0]?.text?.value && ( {message?.content[0]?.text?.value} )} {!message?.content[0]?.text?.value && ( Something went wrong. Please try again. )}

) } return (
Error
setModalTroubleShooting(true)} > Troubleshooting {/* */}
{copied ? ( <> Copied ) : ( <> Copy )}
{getErrorTitle()}
) } export default ErrorMessage