diff --git a/src/modules/lite/explorer/components/VoteDetails.tsx b/src/modules/lite/explorer/components/VoteDetails.tsx index e8060394..0e6c387c 100644 --- a/src/modules/lite/explorer/components/VoteDetails.tsx +++ b/src/modules/lite/explorer/components/VoteDetails.tsx @@ -111,64 +111,67 @@ export const VoteDetails: React.FC<{ {choices && - choices.map((choice: Choice, index) => ( - - - - - {choice.name} - - - - {choice && choice.walletAddresses ? ( + choices.map((choice: Choice, index) => { + const pollWeight = calculateWeight( + poll?.totalSupplyAtReferenceBlock, + calculateChoiceTotal(choice.walletAddresses, tokenData?.decimals), + tokenData?.decimals + ) + .dp(2, 1) + .toNumber() + + const pollWeightXtz = calculateWeight( + poll?.totalSupplyAtReferenceBlock, + calculateChoiceTotal(choice.walletAddresses, isXTZ ? 6 : tokenData?.decimals), + isXTZ ? 6 : tokenData?.decimals + ) + .dp(2, 1) + .toString() + + const calculatedChoiceTotalCount = numbro( + calculateChoiceTotal(choice.walletAddresses, isXTZ ? 6 : tokenData?.decimals) + ).format(formatConfig) + + const tokenSymbol = !isMobile + ? nFormatter(calculateChoiceTotal(choice.walletAddresses, isXTZ ? 6 : tokenData?.decimals), 1) + : calculatedChoiceTotalCount + + const linearProgressValue = !poll?.isXTZ ? pollWeight : calculateWeightXTZ(choice, totalXTZ) + return ( + + + - {choice.walletAddresses.length} Voters -{" "} - {!isMobile - ? nFormatter(calculateChoiceTotal(choice.walletAddresses, isXTZ ? 6 : tokenData?.decimals), 1) - : numbro(calculateChoiceTotal(choice.walletAddresses, isXTZ ? 6 : tokenData?.decimals)).format( - formatConfig - )}{" "} - {isXTZ ? "XTZ" : tokenData?.symbol} + {choice.name} - ) : null} - - - - - + + + {choice && choice.walletAddresses ? ( + + {choice.walletAddresses.length} Voters - {tokenSymbol} {isXTZ ? "XTZ" : tokenData?.symbol} + + ) : null} + - - - {!poll?.isXTZ - ? calculateWeight( - poll?.totalSupplyAtReferenceBlock, - calculateChoiceTotal(choice.walletAddresses, isXTZ ? 6 : tokenData?.decimals), - isXTZ ? 6 : tokenData?.decimals - ) - .dp(2, 1) - .toString() - : numbro(calculateWeightXTZ(choice, totalXTZ)).format(formatConfig)} - % - + + + + + + + {!poll?.isXTZ ? pollWeightXtz : numbro(calculateWeightXTZ(choice, totalXTZ)).format(formatConfig)} + % + + - - - ))} + + ) + })} diff --git a/src/services/lite/utils.ts b/src/services/lite/utils.ts index 88c09e8d..1b6a4640 100644 --- a/src/services/lite/utils.ts +++ b/src/services/lite/utils.ts @@ -137,11 +137,14 @@ export const calculateProposalTotal = (choices: Choice[], decimals: any) => { } const getUsers = (options: Choice[]) => { + console.log("options", options) const addresses: string[] = [] - options.map(option => { - return option.walletAddresses.map(wallet => addresses.push(wallet.address)) + options.forEach(option => { + // TODO: ashutoshpw - Replace with wallet.address + option.walletAddresses.forEach(wallet => addresses.push((wallet as any)?._id)) }) + // debugger return new Set(addresses) }