Skip to content

Commit d1008be

Browse files
committed
fix: format count display for address details to handle large numbers
1 parent ef43122 commit d1008be

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/modules/addresses/address/buildAddressDetails.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
import { AddressQuery } from '@/graphql/graphql';
22

3+
function formatCount(count: number) {
4+
return count >= 1000 ? '1000+' : count;
5+
}
6+
37
export function buildAddressDetails({
48
address,
59
}: {
610
address: AddressQuery['account'];
711
}) {
812
return {
913
...(address?.allApps && {
10-
Apps: <p>{address.allApps.length}</p>,
14+
Apps: <p>{formatCount(address.allApps.length)}</p>,
1115
}),
1216
...(address?.allDatasets && {
13-
Datasets: <p>{address.allDatasets.length}</p>,
17+
Datasets: <p>{formatCount(address.allDatasets.length)}</p>,
1418
}),
1519
...(address?.allWorkerpools && {
16-
Workerpools: <p>{address.allWorkerpools.length}</p>,
20+
Workerpools: <p>{formatCount(address.allWorkerpools.length)}</p>,
1721
}),
1822
...(address?.allContributions && {
19-
Contributions: <p>{address.allContributions.length}</p>,
23+
Contributions: <p>{formatCount(address.allContributions.length)}</p>,
2024
}),
2125
...(address?.score && {
2226
Score: <p>{address.score}</p>,

0 commit comments

Comments
 (0)