Skip to content

Commit

Permalink
pass in valueSuffix to add token symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-aurele-besner committed Aug 9, 2024
1 parent afa57b0 commit 06f13ba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions explorer/src/components/Leaderboard/LeaderboardList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type LeaderboardListProps = {
idLink: (id: string) => string
idLabel?: string
valueType?: 'number' | 'bigNumber'
valueSuffix?: string
showAccountIcon?: boolean
}
type Row = AccountTransferSenderTotalCountQuery['account_transfer_sender_total_count'][0]
Expand All @@ -51,6 +52,7 @@ export const LeaderboardList: FC<LeaderboardListProps> = ({
idLink,
idLabel = 'Account',
valueType = 'bigNumber',
valueSuffix = '',
showAccountIcon = true,
}) => {
const { ref, inView } = useInView()
Expand Down Expand Up @@ -102,6 +104,7 @@ export const LeaderboardList: FC<LeaderboardListProps> = ({
{row.original.value
? `${numberWithCommas(valueType === 'bigNumber' ? bigNumberToNumber(row.original.value) : row.original.value)}`
: 0}
{valueSuffix && ` ${valueSuffix}`}
</div>
),
},
Expand Down
11 changes: 10 additions & 1 deletion explorer/src/components/Leaderboard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
'use client'

import { INTERNAL_ROUTES, Routes } from '@/constants'
import useChains from '@/hooks/useChains'
import { PageTabs } from 'components/common/PageTabs'
import { Tab } from 'components/common/Tabs'
import { TOKEN } from 'constants/general'
import { INTERNAL_ROUTES, Routes } from 'constants/routes'
import useMediaQuery from 'hooks/useMediaQuery'
import useWallet from 'hooks/useWallet'
import React, { FC } from 'react'
Expand Down Expand Up @@ -59,6 +60,7 @@ export const AccountLeaderboard: FC = () => {
query={Query.QUERY_ACCOUNT_TRANSFER_SENDER_TOTAL_VALUE}
table='account_transfer_sender_total_value'
idLink={(id) => INTERNAL_ROUTES.accounts.id.page(network, Routes.consensus, id)}
valueSuffix={TOKEN.symbol}
/>
</Tab>
<Tab title='Transfer Receiver Count'>
Expand All @@ -76,6 +78,7 @@ export const AccountLeaderboard: FC = () => {
query={Query.QUERY_ACCOUNT_TRANSFER_RECEIVER_TOTAL_VALUE}
table='account_transfer_receiver_total_value'
idLink={(id) => INTERNAL_ROUTES.accounts.id.page(network, Routes.consensus, id)}
valueSuffix={TOKEN.symbol}
/>
</Tab>
<Tab title='Remark Count'>
Expand Down Expand Up @@ -120,6 +123,7 @@ export const AccountLeaderboard: FC = () => {
query={Query.QUERY_ACCOUNT_TRANSACTION_FEE_PAID_TOTAL_VALUE}
table='account_transaction_fee_paid_total_value'
idLink={(id) => INTERNAL_ROUTES.accounts.id.page(network, Routes.consensus, id)}
valueSuffix={TOKEN.symbol}
/>
</Tab>
</PageTabs>
Expand Down Expand Up @@ -151,6 +155,7 @@ export const FarmerLeaderboard: FC = () => {
table='farmer_vote_and_block_total_value'
idLabel='Farmer'
idLink={(id) => INTERNAL_ROUTES.accounts.id.page(network, Routes.consensus, id)}
valueSuffix={TOKEN.symbol}
/>
</Tab>
<Tab title='Vote Count'>
Expand All @@ -170,6 +175,7 @@ export const FarmerLeaderboard: FC = () => {
table='farmer_vote_total_value'
idLabel='Farmer'
idLink={(id) => INTERNAL_ROUTES.accounts.id.page(network, Routes.consensus, id)}
valueSuffix={TOKEN.symbol}
/>
</Tab>
<Tab title='Block Count'>
Expand All @@ -189,6 +195,7 @@ export const FarmerLeaderboard: FC = () => {
table='farmer_block_total_value'
idLabel='Farmer'
idLink={(id) => INTERNAL_ROUTES.accounts.id.page(network, Routes.consensus, id)}
valueSuffix={TOKEN.symbol}
/>
</Tab>
</PageTabs>
Expand Down Expand Up @@ -252,6 +259,7 @@ export const OperatorLeaderboard: FC = () => {
table='operator_deposits_total_value'
idLabel='Operator'
idLink={(id) => INTERNAL_ROUTES.operators.id.page(network, Routes.staking, id)}
valueSuffix={TOKEN.symbol}
showAccountIcon={false}
/>
</Tab>
Expand Down Expand Up @@ -295,6 +303,7 @@ export const NominatorLeaderboard: FC = () => {
table='nominator_deposits_total_value'
idLabel='Nominator'
idLink={(id) => INTERNAL_ROUTES.accounts.id.page(network, Routes.consensus, id)}
valueSuffix={TOKEN.symbol}
/>
</Tab>
<Tab title='Withdrawals Count'>
Expand Down

0 comments on commit 06f13ba

Please sign in to comment.