aboutsummaryrefslogtreecommitdiff
path: root/src/components/PollCard
diff options
context:
space:
mode:
authorilyayudovin <ilyayudovin123@gmail.com>2020-06-29 17:31:51 +0300
committerilyayudovin <ilyayudovin123@gmail.com>2020-06-29 17:31:51 +0300
commit856522da17348e54b0d390f10772c21b4029e9bd (patch)
treee3642a46d926b6dc4ceae041083112492486c410 /src/components/PollCard
parent0852cbeea6a3872c4a3a4b7dd974db53eb0a85dd (diff)
downloadwhich-ui-856522da17348e54b0d390f10772c21b4029e9bd.tar.gz
fix: make code redably clear
Diffstat (limited to 'src/components/PollCard')
-rw-r--r--src/components/PollCard/PollCard.tsx9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/components/PollCard/PollCard.tsx b/src/components/PollCard/PollCard.tsx
index f222a63..f82ea44 100644
--- a/src/components/PollCard/PollCard.tsx
+++ b/src/components/PollCard/PollCard.tsx
@@ -72,10 +72,13 @@ const PollCard: React.FC<PropTypes> = ({ initialPoll, navigate }) => {
const handleLeft = () => vote('left');
const handleRight = () => vote('right');
- let leftPercentage = Math.round(100 * (left.votes / (left.votes + right.votes)));
- let rightPercentage = 100 - leftPercentage;
+ let leftPercentage;
+ let rightPercentage;
- if(Number.isNaN(leftPercentage) && Number.isNaN(rightPercentage)){
+ if (left.votes || right.votes) {
+ leftPercentage = Math.round(100 * (left.votes / (left.votes + right.votes)));
+ rightPercentage = 100 - leftPercentage;
+ } else {
leftPercentage = 0;
rightPercentage = 0;
}