blob: 83d6582dc1879236a3b03a25ea3e542fc7fd7265 (
plain)
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
|
import React from 'react';
import { Alert, Snackbar } from '@mui/material';
import { useAppDispatch, useAppSelector } from '../hooks';
import { hideSnackbar, selectUIState } from '../slices/uiSlice';
function GlobalSnackbar() {
const dispatch = useAppDispatch();
const { snackbarOpen, message, severity } = useAppSelector(selectUIState);
const handleClose = () => {
dispatch(hideSnackbar());
};
return (
<Snackbar open={snackbarOpen} onClose={handleClose} autoHideDuration={5000}>
<div>
<Alert severity={severity} onClose={handleClose}>
{message}
</Alert>
</div>
</Snackbar>
);
}
export default GlobalSnackbar;
|