Commit a344becc authored by Yuri Mikhin's avatar Yuri Mikhin Committed by Yuri Mikhin

Add units to number widgets in the Stats.

parent acd2e7ef
...@@ -22,14 +22,23 @@ const NumberWidgetsList = () => { ...@@ -22,14 +22,23 @@ const NumberWidgetsList = () => {
gridGap={ 4 } gridGap={ 4 }
> >
{ isLoading ? skeletonElement : { isLoading ? skeletonElement :
numberWidgetsScheme.map(({ id, title }) => numberWidgetsScheme.map(({ id, title, formatFn }) => {
data?.counters[id] ? ( if (!data?.counters[id]) {
return null;
}
const value = formatNumberToMetricPrefix(Number(data.counters[id]));
return (
<NumberWidget <NumberWidget
key={ id } key={ id }
label={ title } label={ title }
value={ formatNumberToMetricPrefix(Number(data.counters[id])) } value={ formatFn ?
formatFn(value) :
value }
/> />
) : null) } );
}) }
</Grid> </Grid>
); );
}; };
......
...@@ -2,7 +2,7 @@ import type { Stats } from 'types/api/stats'; ...@@ -2,7 +2,7 @@ import type { Stats } from 'types/api/stats';
type Key = keyof Stats['counters']; 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', id: 'totalBlocks',
title: 'Total blocks', title: 'Total blocks',
...@@ -10,6 +10,7 @@ export const numberWidgetsScheme: Array<{id: Key; title: string}> = [ ...@@ -10,6 +10,7 @@ export const numberWidgetsScheme: Array<{id: Key; title: string}> = [
{ {
id: 'averageBlockTime', id: 'averageBlockTime',
title: 'Average block time', title: 'Average block time',
formatFn: (n) => `${ n } s`,
}, },
{ {
id: 'totalTransactions', id: 'totalTransactions',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment