import { useState } from "react"; import { Copy, Check, ArrowLeftRight, Wand2 } from "lucide-react"; import { toast } from "sonner"; import type { FormatResult } from "@/lib/api"; interface FormatterPanelProps { result: FormatResult | null; onApplyToEditor?: (sql: string) => void; } export function FormatterPanel({ result, onApplyToEditor }: FormatterPanelProps) { const [copied, setCopied] = useState(false); const handleCopy = async () => { if (!result) return; await navigator.clipboard.writeText(result.formatted); setCopied(true); toast.success("Copied to clipboard"); setTimeout(() => setCopied(false), 2000); }; const handleApply = () => { if (!result) return; onApplyToEditor?.(result.formatted); toast.success("Applied to editor"); }; if (!result) { return (
Run analysis to see formatted SQL
{result.formatted}