diff options
author | ilyayudovin <ilyayudovin123@gmail.com> | 2020-09-11 02:11:54 +0300 |
---|---|---|
committer | ilyayudovin <ilyayudovin123@gmail.com> | 2020-09-11 02:11:54 +0300 |
commit | 319e7fc67dd4329606b09dca1cb78ea132b1264a (patch) | |
tree | c3df1e8a8ab2095e72a2c449a0efa0c6c42a9c13 /src/components/PollCard/PollCard.tsx | |
parent | 2174c5cb6a5d8a5d9bd61d07e330e4c315b99baf (diff) | |
download | which-ui-319e7fc67dd4329606b09dca1cb78ea132b1264a.tar.gz |
fix eslint errors
Diffstat (limited to 'src/components/PollCard/PollCard.tsx')
-rw-r--r-- | src/components/PollCard/PollCard.tsx | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/src/components/PollCard/PollCard.tsx b/src/components/PollCard/PollCard.tsx index 87d9fae..56f5dbd 100644 --- a/src/components/PollCard/PollCard.tsx +++ b/src/components/PollCard/PollCard.tsx @@ -51,26 +51,9 @@ const PollCard: React.FC<PropTypes> = React.memo(({ poll, setPoll }) => { const { enqueueSnackbar } = useSnackbar(); const { isAuthenticated } = useAuth(); const date: string = new Date(poll.createdAt).toLocaleString('default', DATE_FORMAT); - let timer: any; - let delay = 200; + let timer: ReturnType<typeof setTimeout>; let prevent = false; - const handleClick = (which: Which) => () => { - if(!prevent) { - prevent = true; - timer = setTimeout(() => { - console.log('single click', prevent); - prevent = false; - }, delay) - } - else { - clearTimeout(timer); - prevent = false; - console.log('double click', prevent); - handleVote(which); - } - }; - const handleVote = (which: Which) => { if (!isAuthenticated) { enqueueSnackbar('Unauthorized users can not vote in polls', { @@ -96,6 +79,19 @@ const PollCard: React.FC<PropTypes> = React.memo(({ poll, setPoll }) => { } }; + const handleClick = (which: Which) => () => { + if (!prevent) { + prevent = true; + timer = setTimeout(() => { + prevent = false; + }, 200); + } else { + clearTimeout(timer); + prevent = false; + handleVote(which); + } + }; + let leftPercentage; let rightPercentage; |