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

); } return (
{/* Toolbar */}
{result.changed ? (
{result.fixes_applied} fix{result.fixes_applied !== 1 ? "es" : ""} applied
) : (
No formatting changes needed
)} dialect: {result.dialect}
{/* Diff indicator */} {result.changed && (
Formatted SQL differs from original
)} {/* Formatted SQL output */}
          {result.formatted}
        
); }