aboutsummaryrefslogtreecommitdiff
path: root/src/pages/FeedPage/PollSubmission.tsx
diff options
context:
space:
mode:
authorilyayudovin <ilyayudovin123@gmail.com>2020-06-30 18:41:28 +0300
committerilyayudovin <ilyayudovin123@gmail.com>2020-06-30 18:41:28 +0300
commit75eb28d8338c1e0601c94640303f91ef09bd583a (patch)
tree7f74c2f7b087189ef6cf11d144c607b5a7413f06 /src/pages/FeedPage/PollSubmission.tsx
parentfc552cbf3ffcba6d2cc7003936f4b55378541525 (diff)
downloadwhich-ui-75eb28d8338c1e0601c94640303f91ef09bd583a.tar.gz
feat: add snackbar for showing messages to a user
Diffstat (limited to 'src/pages/FeedPage/PollSubmission.tsx')
-rw-r--r--src/pages/FeedPage/PollSubmission.tsx9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/pages/FeedPage/PollSubmission.tsx b/src/pages/FeedPage/PollSubmission.tsx
index 18f029c..f8ba26b 100644
--- a/src/pages/FeedPage/PollSubmission.tsx
+++ b/src/pages/FeedPage/PollSubmission.tsx
@@ -13,6 +13,7 @@ import UserStrip from '../../components/UserStrip/UserStrip';
import { post } from '../../requests';
import { Contents } from './types';
import { useAuth } from '../../hooks/useAuth';
+import {useSnackbar} from "notistack";
interface PropTypes{
addPoll: (poll: Poll) => void;
@@ -34,6 +35,7 @@ const PollSubmission: React.FC<PropTypes> = ({ addPoll }) => {
const classes = useStyles();
const [expanded, setExpanded] = useState(false);
const [contents, setContents] = useState<Contents>(emptyContents);
+ const { enqueueSnackbar, closeSnackbar } = useSnackbar();
const { user } = useAuth();
const readyToSubmit = contents.left.url && contents.right.url;
@@ -50,12 +52,19 @@ const PollSubmission: React.FC<PropTypes> = ({ addPoll }) => {
if (expanded && readyToSubmit) {
post('/polls/', { contents }).then(response => {
addPoll(response.data);
+ showSnackBar('Your poll has been successfully created!');
});
setContents({ ...emptyContents });
}
setExpanded(!expanded);
};
+ const showSnackBar = (message: string) => {
+ enqueueSnackbar(message, {
+ variant: 'success',
+ });
+ };
+
return (
<ClickAwayListener onClickAway={handleClickAway}>
<Card>