Skip to content

Commit

Permalink
Merge pull request #1201 from ombhardwajj/snackbarcolorfix
Browse files Browse the repository at this point in the history
 #1199 | Snackbar color corrected(changed to red) when profile picture URL incorrect
  • Loading branch information
vinayvenu authored Apr 17, 2024
2 parents e8a4f39 + 45bbd77 commit c3cac9a
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/dataEntryApp/components/CustomizedSnackbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,27 @@ import React from "react";
import PropTypes from "prop-types";
import clsx from "clsx";
import CheckCircleIcon from "@material-ui/icons/CheckCircle";
import { green } from "@material-ui/core/colors";
import ErrorIcon from "@material-ui/icons/Error";
import { red, green } from "@material-ui/core/colors";
import Snackbar from "@material-ui/core/Snackbar";
import SnackbarContent from "@material-ui/core/SnackbarContent";
import { makeStyles } from "@material-ui/core/styles";
import _ from "lodash";

const variantIcon = {
success: CheckCircleIcon
success: CheckCircleIcon,
error: ErrorIcon
};

const useStyles1 = makeStyles(theme => ({
success: {
backgroundColor: green[600],
minWidth: 220
},
error: {
backgroundColor: red[300],
minWidth: 220
},
icon: {
fontSize: 20
},
Expand Down Expand Up @@ -57,6 +63,8 @@ MySnackbarContentWrapper.propTypes = {
};

export default function CustomizedSnackbar({ defaultSnackbarStatus, message, onClose = _.noop }) {
const isError = message === "Profile image URL is not correct or couldn't be loaded.";
const variant = isError ? "error" : "success";
return (
<div>
<Snackbar
Expand All @@ -68,7 +76,7 @@ export default function CustomizedSnackbar({ defaultSnackbarStatus, message, onC
autoHideDuration={2000}
onClose={() => onClose()}
>
<MySnackbarContentWrapper variant="success" message={message} />
<MySnackbarContentWrapper variant={variant} message={message} />
</Snackbar>
</div>
);
Expand Down

0 comments on commit c3cac9a

Please sign in to comment.