Created SnackBar

Co-authored-by: SgtPodding <SgtPodding@users.noreply.github.com>
This commit is contained in:
Kristoffer Juelsenn 2022-04-06 14:13:46 +02:00
parent cd6d00279e
commit 6be3966bab
1 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,29 @@
import * as React from 'react';
import Stack from '@mui/material/Stack';
import Button from '@mui/material/Button';
import Snackbar from '@mui/material/Snackbar';
import MuiAlert from '@mui/material/Alert';
const Alert = React.forwardRef(function Alert(props, ref) {
return <MuiAlert elevation={6} ref={ref} variant="filled" {...props} />;
});
export default function showError(props) {
const handleClose = (event, reason) => {
if (reason === 'clickaway') {
return;
}
props.setOpen(false);
};
return (
<Stack spacing={2} sx={{ width: '100%' }}>
<Snackbar open={props.open} autoHideDuration={6000} onClose={handleClose}>
<Alert onClose={handleClose} severity="error" sx={{ width: '100%' }}>
{props.message}
</Alert>
</Snackbar>
</Stack>
);
}