import { ResultsTable } from "./ResultsTable"; import { ResultsJsonView } from "./ResultsJsonView"; import type { QueryResult } from "@/types"; import { Loader2, AlertCircle, Sparkles, Wand2 } from "lucide-react"; import { Button } from "@/components/ui/button"; interface Props { result?: QueryResult | null; error?: string | null; isLoading?: boolean; viewMode?: "table" | "json"; onCellDoubleClick?: ( rowIndex: number, colIndex: number, value: unknown ) => void; highlightedCells?: Set; aiExplanation?: string | null; isAiLoading?: boolean; onExplainError?: () => void; onFixError?: () => void; } export function ResultsPanel({ result, error, isLoading, viewMode = "table", onCellDoubleClick, highlightedCells, aiExplanation, isAiLoading, onExplainError, onFixError, }: Props) { if (isLoading) { return (
Executing query...
); } if (aiExplanation) { return (
AI Explanation
            {aiExplanation}
          
); } if (error) { return (
{error}
{(onExplainError || onFixError) && (
{onExplainError && ( )} {onFixError && ( )}
)}
); } if (!result) { return (
Press Ctrl+Enter to execute query
); } if (result.columns.length === 0) { return (
Query executed successfully. {result.row_count} rows affected.
); } if (viewMode === "json") { return ( ); } return ( ); }