From 4037868a791c706c4d77d6353e396cb6454995be Mon Sep 17 00:00:00 2001
From: ilyayudovin <ilyayudovin123@gmail.com>
Date: Mon, 29 Jun 2020 14:22:41 +0300
Subject: fix: show zero percentage instead of NaN

---
 src/components/PollCard/PollCard.tsx | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

(limited to 'src/components/PollCard/PollCard.tsx')

diff --git a/src/components/PollCard/PollCard.tsx b/src/components/PollCard/PollCard.tsx
index d3b4fc2..f222a63 100644
--- a/src/components/PollCard/PollCard.tsx
+++ b/src/components/PollCard/PollCard.tsx
@@ -72,8 +72,13 @@ const PollCard: React.FC<PropTypes> = ({ initialPoll, navigate }) => {
   const handleLeft = () => vote('left');
   const handleRight = () => vote('right');
 
-  const leftPercentage = Math.round(100 * (left.votes / (left.votes + right.votes)));
-  const rightPercentage = 100 - leftPercentage;
+  let leftPercentage = Math.round(100 * (left.votes / (left.votes + right.votes)));
+  let rightPercentage = 100 - leftPercentage;
+
+  if(Number.isNaN(leftPercentage) && Number.isNaN(rightPercentage)){
+    leftPercentage = 0;
+    rightPercentage = 0;
+  }
 
   const dominant: Which = left.votes >= right.votes ? 'left' : 'right';
 
-- 
cgit v1.2.3

