Commit 1fac844d authored by Yuri Mikhin's avatar Yuri Mikhin Committed by Yuri Mikhin

Fix stats widgets.

parent d33d6ea6
...@@ -21,11 +21,18 @@ export type GasPrices = { ...@@ -21,11 +21,18 @@ export type GasPrices = {
export type Stats = { export type Stats = {
counters: { counters: {
totalBlocks: string;
averageBlockTime: string; averageBlockTime: string;
totalTransactions: string;
completedTransactions: string; completedTransactions: string;
totalAccounts: string; totalAccounts: string;
totalBlocksAllTime: string;
totalTransactions: string; totalTokens: string;
totalNativeCoinHolders: string;
totalNativeCoinTransfers: string;
}; };
} }
......
...@@ -3,6 +3,7 @@ import React from 'react'; ...@@ -3,6 +3,7 @@ import React from 'react';
import useApiQuery from 'lib/api/useApiQuery'; import useApiQuery from 'lib/api/useApiQuery';
import { numberWidgetsScheme } from './constants/number-widgets-scheme';
import NumberWidget from './NumberWidget'; import NumberWidget from './NumberWidget';
import NumberWidgetSkeleton from './NumberWidgetSkeleton'; import NumberWidgetSkeleton from './NumberWidgetSkeleton';
...@@ -18,30 +19,8 @@ const NumberWidgetsList = () => { ...@@ -18,30 +19,8 @@ const NumberWidgetsList = () => {
> >
{ isLoading ? [ ...Array(skeletonsCount) ] { isLoading ? [ ...Array(skeletonsCount) ]
.map((e, i) => <NumberWidgetSkeleton key={ i }/>) : .map((e, i) => <NumberWidgetSkeleton key={ i }/>) :
( numberWidgetsScheme.map(({ id, title }) =>
<> data?.counters[id] ? <NumberWidget key={ id } label={ title } value={ Number(data.counters[id]).toLocaleString() }/> : null) }
<NumberWidget
label="Total blocks"
value={ Number(data?.counters.totalBlocksAllTime).toLocaleString() }
/>
<NumberWidget
label="Average block time"
value={ Number(data?.counters.averageBlockTime).toLocaleString() }
/>
<NumberWidget
label="Completed transactions"
value={ Number(data?.counters.completedTransactions).toLocaleString() }
/>
<NumberWidget
label="Total transactions"
value={ Number(data?.counters.totalTransactions).toLocaleString() }
/>
<NumberWidget
label="Total accounts"
value={ Number(data?.counters.totalAccounts).toLocaleString() }
/>
</>
) }
</Grid> </Grid>
); );
}; };
......
...@@ -6,7 +6,7 @@ export const statsChartsScheme: Array<StatsSection> = [ ...@@ -6,7 +6,7 @@ export const statsChartsScheme: Array<StatsSection> = [
title: 'Blocks', title: 'Blocks',
charts: [ charts: [
{ {
id: 'new-blocks', id: 'newBlocksPerDay',
title: 'New blocks', title: 'New blocks',
description: 'New blocks number per day', description: 'New blocks number per day',
}, },
......
import type { Stats } from 'types/api/stats';
type Key = keyof Stats['counters'];
export const numberWidgetsScheme: Array<{id: Key; title: string}> = [
{
id: 'totalBlocks',
title: 'Total blocks',
},
{
id: 'averageBlockTime',
title: 'Average block time',
},
{
id: 'totalTransactions',
title: 'Total transactions',
},
{
id: 'completedTransactions',
title: 'Completed transactions',
},
{
id: 'totalAccounts',
title: 'Total accounts',
},
{
id: 'totalTokens',
title: 'Total tokens',
},
{
id: 'totalNativeCoinHolders',
title: 'Total native coin holders',
},
{
id: 'totalNativeCoinTransfers',
title: 'Total native coin transfers',
},
{
id: 'totalAccounts',
title: 'Total accounts',
},
];
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