Skip to content
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.

Commit

Permalink
Improved calcs to work in different scenarios. Solved problem with re…
Browse files Browse the repository at this point in the history
…sponsive not showing the data in mobile
  • Loading branch information
jpaulet committed Mar 28, 2024
1 parent 0228b90 commit a03f0bb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions components/blocks/question-results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ export const QuestionResults = (props: QuestionsResultsProps) => {
//Calculate voting weight
let totalWeightCount = 0;
sortedChoices.map((choice: ChoiceResult, index: number) => {

Check warning on line 81 in components/blocks/question-results.tsx

View workflow job for this annotation

GitHub Actions / node-tests-and-build

'index' is defined but never used
totalWeightCount = (Number(totalWeightCount) + Number(choice.votes));
totalWeightCount = BigInt(totalWeightCount) + BigInt(choice.votes);
})

Check failure on line 83 in components/blocks/question-results.tsx

View workflow job for this annotation

GitHub Actions / node-tests-and-build

Insert `;`
totalWeightCount = BigNumber.from(totalWeightCount)
totalWeightCount = BigNumber.from(totalWeightCount);

return (
<Card isMobile={isMobile}>
Expand Down Expand Up @@ -149,7 +149,7 @@ export const QuestionResults = (props: QuestionsResultsProps) => {
disabled={choice.votes.eq(0)}
/>
</Col>
<Col xs={12} hiddenSmAndUp>
<Col xs={12} hiddenMdAndUp>
<Row align="end" gutter="md">
<Col>
<Text size="lg" weight="bold" color="dark-blue">
Expand Down Expand Up @@ -189,6 +189,7 @@ export const QuestionResults = (props: QuestionsResultsProps) => {
};
const getResults = (result: BigNumber, decimals?: number) =>
decimals ? parseInt(formatUnits(result, decimals), 10) : result;

const getBarPercent = (votes: BigNumber, totalVotes: BigNumber): number => {
if (votes.eq(0)) {
return 1.5;
Expand All @@ -200,7 +201,7 @@ const getPercent = (votes: BigNumber, resultsWeight: BigNumber): number => {

// used to avoid losing decimal precision
const ratio = votes.mul(10000);
return ratio.div(resultsWeight).div(100).toNumber();
return ratio.div(resultsWeight)/100;

Check failure on line 204 in components/blocks/question-results.tsx

View workflow job for this annotation

GitHub Actions / node-tests-and-build

Replace `/` with `·/·`
};
const getStringPercent = (percent: number): string => {
const decimal = percent % 1;
Expand Down

0 comments on commit a03f0bb

Please sign in to comment.