import React from "react";
import { Box, Typography, Alert, Snackbar, List, ListItem, ListItemIcon, ListItemText } from "@mui/material";
import ErrorIcon from "@mui/icons-material/Error";
import WarningIcon from "@mui/icons-material/Warning";
import type { ValidationMessage } from "../types";
interface ValidationAlertProps {
errors: ValidationMessage[];
warnings: ValidationMessage[];
}
export function ValidationAlert({ errors, warnings }: ValidationAlertProps) {
const [warningOpen, setWarningOpen] = React.useState(warnings.length > 0);
if (errors.length > 0) {
return (
OpenAPI Spec Validation Failed
The spec has {errors.length} error{errors.length > 1 ? "s" : ""}. Fix them before the admin panel can render.
{errors.map((e, i) => (
))}
{warnings.length > 0 && (
<>
Warnings ({warnings.length})
{warnings.map((w, i) => (
))}
>
)}
);
}
return (
setWarningOpen(false)}
anchorOrigin={{ vertical: "bottom", horizontal: "center" }}
>
{warnings.map((w, i) => (
setWarningOpen(false)}>
{w.message}
))}
);
}