import { useState } from 'react' import { AlertCircle, AlertTriangle, ChevronDown, ChevronUp, Sparkles, Loader2 } from 'lucide-react' import { cn } from '@/lib/utils' import type { ValidationError } from '@/store/treeEditorStore' interface ValidationSummaryProps { errors: ValidationError[] onSelectNode: (nodeId: string) => void onFixWithAI?: () => void isFixing?: boolean } export function ValidationSummary({ errors, onSelectNode, onFixWithAI, isFixing }: ValidationSummaryProps) { const [isExpanded, setIsExpanded] = useState(true) const errorItems = errors.filter(e => e.severity === 'error') const warningItems = errors.filter(e => e.severity === 'warning') if (errors.length === 0) return null const handleErrorClick = (error: ValidationError) => { if (error.nodeId) { onSelectNode(error.nodeId) } } const hasFixableErrors = errorItems.some(e => e.nodeId) return (
0 ? 'border-red-400/30 bg-red-400/5' : 'border-yellow-400/30 bg-yellow-400/5' )} > {/* Header */}
0 ? 'text-red-400' : 'text-yellow-400' )} > {/* Fix with AI button */} {onFixWithAI && hasFixableErrors && ( )}
{/* Error/Warning List */} {isExpanded && (
{/* Errors */} {errorItems.map((error, index) => ( ))} {/* Warnings */} {warningItems.map((warning, index) => ( ))}
)}
) }