import { Check, Copy } from 'lucide-react' import { useMemo, useState } from 'react' import { Button, cn, copyToClipboard } from 'ui' import { CodeEditor } from '@/components/ui/CodeEditor/CodeEditor' type SqlMonacoBlockProps = { value?: string wrapperClassName?: string } // [Joshen] This is technically a duplicate of CodeBlock from `ui-patterns` // Should decide which is the preferred and consolidate - although rendering CodeEditor // is much heavier due to Monaco Editor. I'd rather we use CodeBlock (or improve that) // for read-only rendering of code contents export const SqlMonacoBlock = ({ value, wrapperClassName }: SqlMonacoBlockProps) => { const [copied, setCopied] = useState(false) const content = useMemo(() => value ?? '', [value]) const handleCopy = (value: string) => { setCopied(true) copyToClipboard(value) setTimeout(() => setCopied(false), 1000) } return (
) }