diff options
author | ilyayudovin <ilyayudovin123@gmail.com> | 2020-07-01 14:38:39 +0300 |
---|---|---|
committer | ilyayudovin <ilyayudovin123@gmail.com> | 2020-07-01 14:38:39 +0300 |
commit | 75c1dac4bceddab1d94b9e43c2fb2035297eb6bd (patch) | |
tree | d2b930d8c4464c64eb5c99077f2d5bbb4f1caf1a /src/components/PollCard/PollCard.tsx | |
parent | 75eb28d8338c1e0601c94640303f91ef09bd583a (diff) | |
download | which-ui-75c1dac4bceddab1d94b9e43c2fb2035297eb6bd.tar.gz |
fix eslint errors
Diffstat (limited to 'src/components/PollCard/PollCard.tsx')
-rw-r--r-- | src/components/PollCard/PollCard.tsx | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/components/PollCard/PollCard.tsx b/src/components/PollCard/PollCard.tsx index aab0261..ef7391e 100644 --- a/src/components/PollCard/PollCard.tsx +++ b/src/components/PollCard/PollCard.tsx @@ -6,10 +6,10 @@ 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'; -import {useSnackbar} from "notistack"; interface PropTypes { initialPoll: Poll; @@ -57,28 +57,28 @@ const PollCard: React.FC<PropTypes> = ({ initialPoll }) => { const [poll, setPoll] = useState<Poll>(initialPoll); const classes = useStyles(); const { author, contents: { left, right }, vote } = poll; - const { enqueueSnackbar, closeSnackbar } = useSnackbar(); + const { enqueueSnackbar } = useSnackbar(); const date: string = new Date(poll.createdAt).toLocaleString('default', DATE_FORMAT); + + const showSnackBar = (message: string) => { + enqueueSnackbar(message, { + variant: 'error' + }); + }; + const handleVote = (which: Which) => { if (vote) { - showSnackBar('You have voted already'); + showSnackBar('You have already voted'); return; } post('votes/', { which, pollId: poll._id }).then(response => { - console.log(response.data); poll.contents[which].votes += 1; poll.vote = response.data; setPoll({ ...poll }); }); }; - const showSnackBar = (message: string) => { - enqueueSnackbar(message, { - variant: 'warning', - }); - }; - const handleLeft = () => handleVote('left'); const handleRight = () => handleVote('right'); |