diff options
author | Eugene Sokolov <eug-vs@keemail.me> | 2020-06-29 22:10:04 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-29 22:10:04 +0300 |
commit | 98c5a70c17416e470544a4b597461771d5a36325 (patch) | |
tree | 10ca1c1f4dd342eaca3ff1aa7698c54ae1e0f10f /src/components/PollCard | |
parent | 699c702ca941c0e7e5fdcb971c9135e28b80c221 (diff) | |
parent | aed13f230d2673a489aec455e48d6edbb503e001 (diff) | |
download | which-ui-98c5a70c17416e470544a4b597461771d5a36325.tar.gz |
Merge pull request #52 from which-ecosystem/pollSubmission
feat: add poll submission component
Diffstat (limited to 'src/components/PollCard')
-rw-r--r-- | src/components/PollCard/PollCard.tsx | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/components/PollCard/PollCard.tsx b/src/components/PollCard/PollCard.tsx index caa2de1..156315a 100644 --- a/src/components/PollCard/PollCard.tsx +++ b/src/components/PollCard/PollCard.tsx @@ -72,8 +72,16 @@ const PollCard: React.FC<PropTypes> = ({ initialPoll, navigate }) => { const handleLeft = () => handleVote('left'); const handleRight = () => handleVote('right'); - const leftPercentage = Math.round(100 * (left.votes / (left.votes + right.votes))); - const rightPercentage = 100 - leftPercentage; + let leftPercentage; + let rightPercentage; + + if (left.votes || right.votes) { + leftPercentage = Math.round(100 * (left.votes / (left.votes + right.votes))); + rightPercentage = 100 - leftPercentage; + } else { + leftPercentage = 0; + rightPercentage = 0; + } const dominant: Which = left.votes >= right.votes ? 'left' : 'right'; |