File size: 1,025 Bytes
6c2bcb4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import Button from "@mui/material/Button";
import Snackbar from "@mui/material/Snackbar";
import IconButton from "@mui/material/IconButton";
import CloseIcon from "@mui/icons-material/Close";
import { SyntheticEvent } from "react";
import { Alert, SnackbarContent } from "@mui/material";

interface SnackbarProps {
	showError: boolean;
	handleClose: (event: SyntheticEvent | Event, reason?: string) => void;
	message: string;
}

export default function SimpleSnackbar({ showError, handleClose, message }: SnackbarProps) {
	const action = (
		<>
			<Button color="secondary" size="small" onClick={handleClose}>
				UNDO
			</Button>
			<IconButton size="small" aria-label="close" color="inherit" onClick={handleClose}>
				<CloseIcon fontSize="small" />
			</IconButton>
		</>
	);

	return (
		<Snackbar
			open={showError}
			autoHideDuration={6000}
			onClose={handleClose}
			action={action}
			anchorOrigin={{ vertical: "bottom", horizontal: "right" }}
		>
			<Alert severity="error">{message}</Alert>
		</Snackbar>
	);
}