diff options
author | ilyayudovin <46264063+ilyayudovin@users.noreply.github.com> | 2020-07-01 18:43:54 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-01 18:43:54 +0300 |
commit | 0b234a7ae255990d71f847a5519482ccb0d83fcb (patch) | |
tree | 7cfd6ff4b8bd154074b9a42aaf4efe5b9cd471e6 /src/components/PollCard/PollCard.tsx | |
parent | fc552cbf3ffcba6d2cc7003936f4b55378541525 (diff) | |
parent | f9999d6da7752a55ad01f85dce34086c1acbff5a (diff) | |
download | which-ui-0b234a7ae255990d71f847a5519482ccb0d83fcb.tar.gz |
Merge pull request #55 from which-ecosystem/snackbar
snackbar
Diffstat (limited to 'src/components/PollCard/PollCard.tsx')
-rw-r--r-- | src/components/PollCard/PollCard.tsx | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/components/PollCard/PollCard.tsx b/src/components/PollCard/PollCard.tsx index 2a23522..12f7198 100644 --- a/src/components/PollCard/PollCard.tsx +++ b/src/components/PollCard/PollCard.tsx @@ -6,7 +6,7 @@ import { CardMedia } from '@material-ui/core/'; import { Which, Poll } from 'which-types'; - +import { useSnackbar } from 'notistack'; import PercentageBar from './PercentageBar'; import UserStrip from '../UserStrip/UserStrip'; import { post } from '../../requests'; @@ -57,10 +57,16 @@ const PollCard: React.FC<PropTypes> = ({ initialPoll }) => { const [poll, setPoll] = useState<Poll>(initialPoll); const classes = useStyles(); const { author, contents: { left, right }, vote } = poll; + const { enqueueSnackbar } = useSnackbar(); const date: string = new Date(poll.createdAt).toLocaleString('default', DATE_FORMAT); const handleVote = (which: Which) => { - if (vote) return; + if (vote) { + enqueueSnackbar('You have already voted', { + variant: 'error' + }); + return; + } post('votes/', { which, pollId: poll._id }).then(response => { poll.contents[which].votes += 1; poll.vote = response.data; |