summaryrefslogtreecommitdiffstats
path: root/front/odiparpack/app/components/Notification/Notification.js
diff options
context:
space:
mode:
authorDayana31 <[email protected]>2022-06-01 16:43:23 -0500
committerDayana31 <[email protected]>2022-06-01 16:43:23 -0500
commitec0c33156713e51c64f2a9de4f932cd5507c654b (patch)
treecc46421686a49bbc0a0c343e460c13a21af1015d /front/odiparpack/app/components/Notification/Notification.js
parent6971201caffc2fccee5bfb12e88e5510c85eeb49 (diff)
parente9cb09907f8dbc9a4a64549a3ea4d1d8313e7c25 (diff)
downloadDP1_project-ec0c33156713e51c64f2a9de4f932cd5507c654b.tar.gz
DP1_project-ec0c33156713e51c64f2a9de4f932cd5507c654b.tar.bz2
DP1_project-ec0c33156713e51c64f2a9de4f932cd5507c654b.zip
Merge branch 'develop' into dayana
Diffstat (limited to 'front/odiparpack/app/components/Notification/Notification.js')
-rw-r--r--front/odiparpack/app/components/Notification/Notification.js69
1 files changed, 60 insertions, 9 deletions
diff --git a/front/odiparpack/app/components/Notification/Notification.js b/front/odiparpack/app/components/Notification/Notification.js
index 7e73896..fcc53a4 100644
--- a/front/odiparpack/app/components/Notification/Notification.js
+++ b/front/odiparpack/app/components/Notification/Notification.js
@@ -2,8 +2,13 @@ import React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import CloseIcon from '@material-ui/icons/Close';
+import classNames from 'classnames';
+import CheckCircleOutlinedIcon from '@material-ui/icons/CheckCircleOutlined';
+import ErrorOutlineOutlinedIcon from '@material-ui/icons/ErrorOutlineOutlined';
+import InfoOutlinedIcon from '@material-ui/icons/InfoOutlined';
+import ReportProblemOutlinedIcon from '@material-ui/icons/ReportProblemOutlined';
-import { Snackbar, IconButton } from '@material-ui/core';
+import { Snackbar, IconButton, SnackbarContent } from '@material-ui/core';
const styles = theme => ({
close: {
@@ -11,6 +16,41 @@ const styles = theme => ({
},
});
+const variantIcon = {
+ success: CheckCircleOutlinedIcon,
+ warning: ReportProblemOutlinedIcon,
+ error: ErrorOutlineOutlinedIcon,
+ info: InfoOutlinedIcon,
+};
+
+const styles1 = theme => ({
+ success: {
+ backgroundColor: '#b6f8c4',
+ },
+ error: {
+ backgroundColor: '#faabab',
+ },
+ info: {
+ backgroundColor: '#b2e7f5',
+ },
+ warning: {
+ backgroundColor: '#f5ea9f',
+ },
+ icon: {
+ fontSize: 20,
+ color: 'black'
+ },
+ iconVariant: {
+ opacity: 0.9,
+ marginRight: theme.spacing(1),
+ },
+ message: {
+ display: 'flex',
+ alignItems: 'center',
+ color: 'black'
+ },
+});
+
class Notification extends React.Component {
handleClose = (event, reason) => {
if (reason === 'clickaway') {
@@ -20,20 +60,30 @@ class Notification extends React.Component {
};
render() {
- const { classes, message } = this.props;
+ const { classes, message, variant } = this.props;
+ const Icon = variantIcon[variant];
return (
<Snackbar
- anchorOrigin={{
- vertical: 'bottom',
- horizontal: 'left',
- }}
open={message !== ''}
autoHideDuration={3000}
onClose={() => this.handleClose()}
ContentProps={{
'aria-describedby': 'message-id',
}}
- message={message}
+ anchorOrigin={{
+ vertical: 'top',
+ horizontal: 'right',
+ }}
+
+ >
+ <SnackbarContent
+ className={classNames(classes[variant])}
+ message={(
+ <span id="client-snackbar" className={classes.message}>
+ <Icon className={classNames(classes.icon, classes.iconVariant)} />
+ {message}
+ </span>
+ )}
action={[
<IconButton
key="close"
@@ -42,10 +92,11 @@ class Notification extends React.Component {
className={classes.close}
onClick={() => this.handleClose()}
>
- <CloseIcon />
+ <CloseIcon className={classes.icon}/>
</IconButton>,
]}
/>
+ </Snackbar>
);
}
}
@@ -56,4 +107,4 @@ Notification.propTypes = {
message: PropTypes.string.isRequired,
};
-export default withStyles(styles)(Notification);
+export default withStyles(styles1)(Notification);