import { Alert, AlertDescription, AlertTitle } from "@/src/components/ui/alert"; import { AlertCircle } from "lucide-react"; type DatasetError = { datasetId: string; datasetName: string; field: "input" | "expectedOutput"; errors: Array<{ path: string; message: string; }>; }; type DatasetItemSchemaErrorsProps = { errors: DatasetError[]; }; export const DatasetItemSchemaErrors: React.FC< DatasetItemSchemaErrorsProps > = ({ errors }) => { if (errors.length === 0) return null; // Group errors by dataset const errorsByDataset = errors.reduce( (acc, error) => { const key = error.datasetId; if (!acc[key]) { acc[key] = { datasetName: error.datasetName, errors: [], }; } acc[key].errors.push(error); return acc; }, {} as Record, ); return ( Schema Validation Failed

The data does not match the required schema for this dataset.

{Object.entries(errorsByDataset).map(([datasetId, datasetErrors]) => (
{Object.keys(errorsByDataset).length > 1 && (
{datasetErrors.datasetName}
)} {datasetErrors.errors.map((error, idx) => (
{error.field === "input" ? "Input" : "Expected Output"}
    {error.errors.map((err, errIdx) => (
  • {err.path === "/" ? ( {err.message} ) : ( {err.path.replace(/^\//, "")} : {err.message} )}
  • ))}
))}
))}
); };