mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
Add units to number widgets in the Stats.
This commit is contained in:
@@ -22,14 +22,23 @@ const NumberWidgetsList = () => {
|
||||
gridGap={ 4 }
|
||||
>
|
||||
{ isLoading ? skeletonElement :
|
||||
numberWidgetsScheme.map(({ id, title }) =>
|
||||
data?.counters[id] ? (
|
||||
numberWidgetsScheme.map(({ id, title, formatFn }) => {
|
||||
if (!data?.counters[id]) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const value = formatNumberToMetricPrefix(Number(data.counters[id]));
|
||||
|
||||
return (
|
||||
<NumberWidget
|
||||
key={ id }
|
||||
label={ title }
|
||||
value={ formatNumberToMetricPrefix(Number(data.counters[id])) }
|
||||
value={ formatFn ?
|
||||
formatFn(value) :
|
||||
value }
|
||||
/>
|
||||
) : null) }
|
||||
);
|
||||
}) }
|
||||
</Grid>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { Stats } from 'types/api/stats';
|
||||
|
||||
type Key = keyof Stats['counters'];
|
||||
|
||||
export const numberWidgetsScheme: Array<{id: Key; title: string}> = [
|
||||
export const numberWidgetsScheme: Array<{id: Key; title: string; formatFn?: (n: string) => string}> = [
|
||||
{
|
||||
id: 'totalBlocks',
|
||||
title: 'Total blocks',
|
||||
@@ -10,6 +10,7 @@ export const numberWidgetsScheme: Array<{id: Key; title: string}> = [
|
||||
{
|
||||
id: 'averageBlockTime',
|
||||
title: 'Average block time',
|
||||
formatFn: (n) => `${ n } s`,
|
||||
},
|
||||
{
|
||||
id: 'totalTransactions',
|
||||
|
||||
Reference in New Issue
Block a user