Create AuthAlert component

This commit is contained in:
2024-05-20 04:16:41 +04:00
parent aab70456f0
commit 64314eed25
+35
View File
@@ -0,0 +1,35 @@
import PropTypes from 'prop-types'
import Snackbar from '@mui/material/Snackbar'
import Alert from '@mui/material/Alert'
export default function AuthAlert({isOpen, setIsOpen, message, severity}) {
const handleClose = (event, reason) => {
if (reason === 'clickaway') {
return
}
setIsOpen(false)
}
return (
<div>
<Snackbar open={isOpen} autoHideDuration={6000} onClose={handleClose}>
<Alert
severity={severity}
variant='filled'
sx={{width: '100%'}}
onClose={handleClose}
>
{message}
</Alert>
</Snackbar>
</div>
)
}
AuthAlert.propTypes = {
isOpen: PropTypes.bool.isRequired,
setIsOpen: PropTypes.func.isRequired,
message: PropTypes.string.isRequired,
severity: PropTypes.string.isRequired
}