Skip to content

Commit

Permalink
fix: format percentage values in delegates page (#462)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaituVR authored Jul 4, 2024
1 parent 1ea739d commit 4c0b06f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions apps/ui/src/components/SpaceDelegates.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { _n, shorten } from '@/helpers/utils';
import { _n, _p, shorten } from '@/helpers/utils';
import { getNetwork } from '@/networks';
import { Space, SpaceMetadataDelegation } from '@/types';
Expand Down Expand Up @@ -131,13 +131,13 @@ watchEffect(() => setTitle(`Delegates - ${props.space.name}`));
class="hidden md:flex w-[20%] flex-col items-end justify-center leading-[22px] truncate"
>
<h4 class="text-skin-link" v-text="_n(delegate.tokenHoldersRepresentedAmount)" />
<div class="text-[17px]" v-text="`${delegate.delegatorsPercentage.toFixed(3)}%`" />
<div class="text-[17px]" v-text="_p(delegate.delegatorsPercentage)" />
</div>
<div
class="w-[40%] md:w-[20%] flex flex-col items-end justify-center pr-4 leading-[22px] truncate"
>
<h4 class="text-skin-link" v-text="_n(delegate.delegatedVotes)" />
<div class="text-[17px]" v-text="`${delegate.votesPercentage.toFixed(3)}%`" />
<div class="text-[17px]" v-text="_p(delegate.votesPercentage)" />
</div>
</div>
<template #loading>
Expand Down
5 changes: 2 additions & 3 deletions apps/ui/src/composables/useDelegates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,9 @@ export function useDelegates(delegationApiUrl: string, governance: string) {

const newDelegates = delegatesData.map((delegate: ApiDelegate) => {
const delegatorsPercentage =
(Number(delegate.tokenHoldersRepresentedAmount) / Number(governanceData.totalDelegates)) *
100;
Number(delegate.tokenHoldersRepresentedAmount) / Number(governanceData.totalDelegates);
const votesPercentage =
(Number(delegate.delegatedVotes) / Number(governanceData.delegatedVotes)) * 100 || 0;
Number(delegate.delegatedVotes) / Number(governanceData.delegatedVotes) || 0;

return {
name: names[delegate.user] || null,
Expand Down

0 comments on commit 4c0b06f

Please sign in to comment.