From 9172b4444d37011dbfe4b526948a1f1c9ad8d178 Mon Sep 17 00:00:00 2001 From: RaduCStefanescu Date: Sat, 26 Sep 2020 19:31:11 +0300 Subject: [PATCH] Update percentage on map --- package.json | 2 +- .../ElectionResultsSummarySection.tsx | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 5786ec2..a0ef427 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@code4ro/reusable-components", - "version": "0.1.27", + "version": "0.1.28", "description": "Component library for code4ro", "keywords": [ "code4ro", diff --git a/src/components/ElectionResultsSummarySection/ElectionResultsSummarySection.tsx b/src/components/ElectionResultsSummarySection/ElectionResultsSummarySection.tsx index 4acfc38..b288fd8 100644 --- a/src/components/ElectionResultsSummarySection/ElectionResultsSummarySection.tsx +++ b/src/components/ElectionResultsSummarySection/ElectionResultsSummarySection.tsx @@ -42,6 +42,18 @@ export const ElectionResultsSummarySection = themable( const completeness = electionScopeIsComplete(scope); const topCandidate = results?.candidates && results.candidates[0]; + const votes = topCandidate?.votes; + let percentage = formatPercentage(fractionOf(votes || 0, results?.validVotes || 0)); + if ( + meta && + meta.type === "referendum" && + topCandidate && + topCandidate.name === "NU AU VOTAT" && + results && + results.eligibleVoters + ) { + percentage = formatPercentage(fractionOf(topCandidate.votes, results.eligibleVoters)); + } const map = width != null && ( ( > {topCandidate && (
-
- {formatPercentage(fractionOf(topCandidate.votes, results?.validVotes || 0))} -
+
{percentage}
{topCandidate.shortName || topCandidate.name}
)}