import { useState } from 'react'; import { AlertCircle, ChevronDown } from 'lucide-react'; import { AlertDialog, AlertDialogAction, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from '@/components/ui/alert-dialog'; import { Alert, AlertDescription } from '@/components/ui/alert'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible'; import { ValidationError } from '@/lib/entityValidationSchemas'; interface ValidationBlockerDialogProps { open: boolean; onClose: () => void; blockingErrors: ValidationError[]; itemNames: string[]; } export function ValidationBlockerDialog({ open, onClose, blockingErrors, itemNames, }: ValidationBlockerDialogProps) { const [showDetails, setShowDetails] = useState(false); return ( Cannot Approve: Validation Errors The following items have blocking validation errors that MUST be fixed before approval. Edit the items to fix the errors, or reject them.
{itemNames.map((name, index) => { const itemErrors = blockingErrors.filter((_, i) => itemNames.length === 1 || i === index ); return (
{name} {itemErrors.length} error{itemErrors.length > 1 ? 's' : ''}
{itemErrors.map((error, errIndex) => (
{error.field}: {error.message}
))}
); })}
{JSON.stringify(blockingErrors, null, 2)}
Close
); }