Spaces:
Runtime error

echem-agent / frontend /src /components /molecules /ReactionViewer.tsx
SII-gelingli
Initial deployment to HF Spaces
ccab613
Raw History Blame Contribute Delete
835 Bytes
import { useState, useEffect } from 'react';
import apiClient from '../../api/client';
interface ReactionViewerProps {
reactionSmiles: string;
width?: number;
height?: number;
}
export default function ReactionViewer({ reactionSmiles, width = 600, height = 200 }: ReactionViewerProps) {
const [svg, setSvg] = useState<string>('');
useEffect(() => {
apiClient
.post('/molecules/render-reaction', {
reaction_smiles: reactionSmiles,
width,
height,
}, { responseType: 'text' })
.then((res) => setSvg(res.data))
.catch(() => setSvg(''));
}, [reactionSmiles, width, height]);
if (!svg) return null;
return (
<div
dangerouslySetInnerHTML={{ __html: svg }}
style={{ border: '1px solid #f0f0f0', borderRadius: 4, padding: 8, marginTop: 8 }}
/>
);
}