mirror of
https://github.com/Qortal/Qortal-Hub.git
synced 2025-05-18 07:36:58 +00:00
44 lines
913 B
TypeScript
44 lines
913 B
TypeScript
import Snackbar, { SnackbarCloseReason } from '@mui/material/Snackbar';
|
|
import Alert from '@mui/material/Alert';
|
|
|
|
export const CustomizedSnackbars = ({
|
|
open,
|
|
setOpen,
|
|
info,
|
|
setInfo,
|
|
duration,
|
|
}) => {
|
|
const handleClose = (
|
|
event?: React.SyntheticEvent | Event,
|
|
reason?: SnackbarCloseReason
|
|
) => {
|
|
if (reason === 'clickaway') {
|
|
return;
|
|
}
|
|
setOpen(false);
|
|
setInfo(null);
|
|
};
|
|
|
|
if (!open) return null;
|
|
|
|
return (
|
|
<div>
|
|
<Snackbar
|
|
anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}
|
|
open={open}
|
|
autoHideDuration={info?.duration === null ? null : duration || 6000}
|
|
onClose={handleClose}
|
|
>
|
|
<Alert
|
|
onClose={handleClose}
|
|
severity={info?.type}
|
|
variant="filled"
|
|
sx={{ width: '100%' }}
|
|
>
|
|
{info?.message}
|
|
</Alert>
|
|
</Snackbar>
|
|
</div>
|
|
);
|
|
};
|