Add units to number widgets in the Stats.

This commit is contained in:
Yuri Mikhin
2023-01-03 23:20:05 +03:00
committed by Yuri Mikhin
parent 08769c84a2
commit ceefa93ebb
2 changed files with 15 additions and 5 deletions
+13 -4
View File
@@ -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 -1
View File
@@ -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',