import React from 'react'; import { AlertCircle, CheckCircle, AlertTriangle, Lightbulb, } from 'lucide-react'; import { Alert, AlertDescription } from '@/components/alert/alert'; import type { ValidationResult } from '@/lib/data/sql-import/sql-validator'; interface SQLValidationStatusProps { validation: ValidationResult | null; errorMessage: string; isAutoFixing?: boolean; onErrorClick?: (line: number) => void; } export const SQLValidationStatus: React.FC = ({ validation, errorMessage, isAutoFixing = false, onErrorClick, }) => { if (!validation && !errorMessage && !isAutoFixing) return null; const hasErrors = validation?.errors && validation.errors.length > 0; const hasWarnings = validation?.warnings && validation.warnings.length > 0; const wasAutoFixed = validation?.warnings?.some((w) => w.message.includes('Auto-fixed')) || false; // If we have parser errors (errorMessage) after validation if (errorMessage && !hasErrors) { return ( {errorMessage} ); } return (
{isAutoFixing && ( Auto-fixing SQL syntax errors... )} {hasErrors && !isAutoFixing && (
SQL Syntax Errors:
{validation.errors.slice(0, 3).map((error, idx) => (
•{' '} : {error.message} {error.suggestion && (
→ {error.suggestion}
)}
))} {validation.errors.length > 3 && (
... and {validation.errors.length - 3} more errors
)}
)} {wasAutoFixed && !hasErrors && ( SQL syntax errors were automatically fixed. Your SQL is now ready to import. )} {hasWarnings && !hasErrors && (
Import Warnings:
{validation.warnings.map((warning, idx) => (
• {warning.message}
))}
)} {!hasErrors && !hasWarnings && !errorMessage && validation && ( SQL syntax validated successfully )}
); };