[#121] added error handler and snackbar

This commit is contained in:
Camille Moussu
2025-10-08 18:14:15 +02:00
committed by Benoit TELLIER
parent f498309f44
commit a00f179dbd
6 changed files with 187 additions and 51 deletions
+38
View File
@@ -0,0 +1,38 @@
import Snackbar from "@mui/material/Snackbar";
import Alert from "@mui/material/Alert";
import Button from "@mui/material/Button";
interface Props {
messages: string[];
onClose: () => void;
}
export function EventErrorSnackbar({ messages, onClose }: Props) {
const open = messages.length > 0;
const summary =
messages.length === 1
? messages[0]
: `${messages.length} events with errors`;
return (
<Snackbar
open={open}
autoHideDuration={6000}
onClose={onClose}
anchorOrigin={{ vertical: "bottom", horizontal: "center" }}
>
<Alert
severity="error"
onClose={onClose}
sx={{ width: "100%" }}
action={
<Button color="inherit" size="small" onClick={onClose}>
OK
</Button>
}
>
{summary}
</Alert>
</Snackbar>
);
}