From 561f9d0d6a1ed378cdf5df2a6b6b130e390661bf Mon Sep 17 00:00:00 2001 From: emmanuelokoye Date: Tue, 8 Feb 2022 07:10:29 +0100 Subject: [PATCH] remove payout column if value is nil --- packages/react-app/src/routes/party/Party.jsx | 2 +- .../src/routes/party/components/ViewTable.jsx | 33 ++++++++----------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/packages/react-app/src/routes/party/Party.jsx b/packages/react-app/src/routes/party/Party.jsx index b75320f..1a5b5de 100644 --- a/packages/react-app/src/routes/party/Party.jsx +++ b/packages/react-app/src/routes/party/Party.jsx @@ -99,7 +99,7 @@ export default function Party({ console.log(error); return null; } - }, [partyData, strategy]); + }, [partyData, strategy, amountToDistribute]); const cachedVoteTable = useMemo(() => { try { diff --git a/packages/react-app/src/routes/party/components/ViewTable.jsx b/packages/react-app/src/routes/party/components/ViewTable.jsx index 28a2d1a..0a51f93 100644 --- a/packages/react-app/src/routes/party/components/ViewTable.jsx +++ b/packages/react-app/src/routes/party/components/ViewTable.jsx @@ -1,14 +1,4 @@ -import { - Box, - Center, - Table, - Thead, - Tbody, - Tfoot, - Tr, - Th, - Td, -} from "@chakra-ui/react"; +import { Box, Center, Table, Thead, Tbody, Tfoot, Tr, Th, Td } from "@chakra-ui/react"; import React, { useState, useMemo } from "react"; import AddressChakra from "../../../components/AddressChakra"; @@ -18,7 +8,8 @@ export const ViewTable = ({ partyData, mainnetProvider, votesData, distribution, const candidateRows = useMemo(() => { const ballotVotes = votesData && votesData[0] && JSON.parse(votesData[0].data.ballot.votes); - const dist = distribution && distribution.reduce((obj, item) => Object.assign(obj, { [item.address]: item.score }), {}); + const dist = + distribution && distribution.reduce((obj, item) => Object.assign(obj, { [item.address]: item.score }), {}); const row = partyData && partyData.candidates && @@ -39,9 +30,11 @@ export const ViewTable = ({ partyData, mainnetProvider, votesData, distribution,
{!isNaN(dist[d] * 1) && dist && (dist[d] * 100).toFixed(2)}%
- -
{!isNaN(dist[d]) ? (dist[d] * amountToDistribute).toFixed(2) : amountToDistribute}
- + {amountToDistribute ? ( + +
{(dist[d] * amountToDistribute).toFixed(2)}
+ + ) : null} ); @@ -49,7 +42,7 @@ export const ViewTable = ({ partyData, mainnetProvider, votesData, distribution, setCastVotes(ballotVotes); return row; - }, [partyData, votesData, distribution, strategy, amountToDistribute]); + }, [partyData, votesData, distribution, strategy, amountToDistribute]); return ( @@ -65,9 +58,11 @@ export const ViewTable = ({ partyData, mainnetProvider, votesData, distribution,
{`Score (${strategy})`}
- -
{"possible payout"}
- + {amountToDistribute ? ( + +
{"Payout"}
+ + ) : null} {candidateRows}