diff --git a/components/Account/Modal.js b/components/Account/Modal.js
index 020c2eb..44b98ec 100644
--- a/components/Account/Modal.js
+++ b/components/Account/Modal.js
@@ -1,12 +1,12 @@
import { useState } from 'react';
import PropTypes from 'prop-types';
import {
- Button, Modal, makeStyles, Snackbar,
+ Button, Modal, makeStyles,
} from '@material-ui/core';
-import Alert from '@material-ui/lab/Alert';
import api from '../../utils/api';
import { useAuth } from '../../src/contexts/auth';
+import SnackAlert from '../shared/alert';
function getModalStyle() {
const top = 50;
@@ -90,26 +90,8 @@ function DeleteAccountModal({ open, setOpen }) {
>
Delete Account
-
-
- Account has been deleted. Redirecting...
-
-
-
-
- Some error occurred. Please try again later.
-
-
+
+
);
diff --git a/components/Editor/index.js b/components/Editor/index.js
index b98266f..a8b68ef 100644
--- a/components/Editor/index.js
+++ b/components/Editor/index.js
@@ -4,9 +4,7 @@ import {
Button,
makeStyles,
Grid,
- Snackbar,
} from '@material-ui/core';
-import Alert from '@material-ui/lab/Alert';
import PropTypes from 'prop-types';
import { Formik, Form } from 'formik';
import { useRouter } from 'next/router';
@@ -20,6 +18,7 @@ import EnvironmentVariablesCard from './EnvironmentVariablesCard';
import HeadersCard from './HeadersCard';
import api from '../../utils/api';
+import SnackAlert from '../shared/alert';
const useStyles = makeStyles((theme) => ({
root: {
@@ -198,26 +197,8 @@ function Editor({ bridge, isEditView }) {
-
-
- Bridge has been saved.
-
-
-
-
- Some error has occured. Please try again.
-
-
+
+
>
);
}
diff --git a/components/shared/alert/index.js b/components/shared/alert/index.js
new file mode 100644
index 0000000..8b0126f
--- /dev/null
+++ b/components/shared/alert/index.js
@@ -0,0 +1,33 @@
+import PropTypes from 'prop-types';
+import { Snackbar } from '@material-ui/core';
+import Alert from '@material-ui/lab/Alert';
+
+function SnackAlert({
+ open, severity, message, onClose,
+}) {
+ return (
+
+
+ { message }
+
+
+ );
+}
+
+export default SnackAlert;
+
+SnackAlert.propTypes = {
+ open: PropTypes.bool.isRequired,
+ onClose: PropTypes.func,
+ severity: PropTypes.string.isRequired,
+ message: PropTypes.string.isRequired,
+};
+
+SnackAlert.defaultProps = {
+ onClose: () => {},
+};
diff --git a/pages/users/account.js b/pages/users/account.js
index a00a1f5..6f7809a 100644
--- a/pages/users/account.js
+++ b/pages/users/account.js
@@ -7,9 +7,7 @@ import {
Container,
Grid,
Typography,
- Snackbar,
} from '@material-ui/core';
-import Alert from '@material-ui/lab/Alert';
import { TextField, CheckboxWithLabel } from 'formik-material-ui';
import Navbar from '../../components/shared/dashboard/Navbar';
@@ -19,6 +17,7 @@ import ProtectRoute from '../../utils/ProtectRoute';
import api from '../../utils/api';
import fetchDataOrRedirect from '../../utils/ssrRedirect';
+import SnackAlert from '../../components/shared/alert';
function Account({ user }) {
const [open, setOpen] = useState(false);
@@ -212,26 +211,8 @@ function Account({ user }) {
)}
-
-
- Account info has been updated.
-
-
-
-
- Some error occurred. Please try again later.
-
-
+
+
);
}
diff --git a/pages/users/signup.js b/pages/users/signup.js
index 4772bfa..8652b01 100644
--- a/pages/users/signup.js
+++ b/pages/users/signup.js
@@ -7,9 +7,7 @@ import {
makeStyles,
Link,
Paper,
- Snackbar,
} from '@material-ui/core';
-import Alert from '@material-ui/lab/Alert';
import { useRouter } from 'next/router';
import { Formik, Form, Field } from 'formik';
@@ -18,6 +16,7 @@ import { TextField } from 'formik-material-ui';
import { useAuth } from '../../src/contexts/auth';
import emailValidator from '../../utils/emailValidator';
import api from '../../utils/api';
+import SnackAlert from '../../components/shared/alert';
const useStyles = makeStyles((theme) => ({
paper: {
@@ -179,26 +178,8 @@ function Signup() {
-
-
- Account has been created. Redirecting...
-
-
-
-
- Some error occurred. Please try again.
-
-
+
+
);
}