From 4ff10aa2629774a4ec2c3050822d9f70d5fce3f2 Mon Sep 17 00:00:00 2001 From: Manuel Calavera Date: Mon, 21 Oct 2019 17:25:30 -0700 Subject: [PATCH] fix: better table and values styles --- src/v2/components/TourDeSol/Table/index.jsx | 41 +++++++++++++++------ src/v2/components/TourDeSol/index.jsx | 5 ++- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/src/v2/components/TourDeSol/Table/index.jsx b/src/v2/components/TourDeSol/Table/index.jsx index c7bec8b9..22e63d3e 100644 --- a/src/v2/components/TourDeSol/Table/index.jsx +++ b/src/v2/components/TourDeSol/Table/index.jsx @@ -11,30 +11,31 @@ import {map} from 'lodash/fp'; import Table from 'v2/components/UI/Table'; import HelpLink from 'v2/components/HelpLink'; import ValidatorName from 'v2/components/UI/ValidatorName'; + import useStyles from './styles'; const fields = [ { label: 'ranking', - name: 'ranking', + id: 'rank', text: '', term: '', }, { label: 'name', - name: 'name', + id: 'name', text: '', term: '', }, { label: 'Staked sol', - name: 'staked_sol', + id: 'activatedStake', text: '', term: '', }, { label: 'Uptime', - name: 'uptime', + id: 'uptimePercent', text: '', term: '', }, @@ -43,9 +44,11 @@ const fields = [ const ValidatorsTable = ({ activeValidators, separate, + totalStaked, }: { activeValidators: Array, separate: boolean, + totalStaked: number, }) => { const classes = useStyles(); const theme = useTheme(); @@ -53,19 +56,32 @@ const ValidatorsTable = ({ const renderRow = ({data: row}) => { const {name, pubkey, avatarUrl, activatedStake, uptimePercent, rank} = row; + const uptime = + uptimePercent > 100 + ? 100 + : parseFloat(uptimePercent.toFixed(uptimePercent ? 4 : 2)); return ( - {rank} + {rank} - {activatedStake.toFixed(8)} - {uptimePercent}% + + {activatedStake.toFixed(8) || 'N/A'} ( + {(100 * (activatedStake / totalStaked)).toFixed(3)}%) + + + {(uptime && `${uptime}%`) || 'Unavailable'} + ); }; const renderCard = card => { const {name, pubkey, avatarUrl, activatedStake, uptimePercent} = card; + const uptime = + uptimePercent > 100 + ? 100 + : parseFloat(uptimePercent.toFixed(uptimePercent ? 4 : 2)); return (
- +
Stake
-
{activatedStake.toFixed(4)}
+
+ {activatedStake.toFixed(4) || 'N/A'}( + {(100 * (activatedStake / totalStaked)).toFixed(3)}%) +
- +
Uptime
-
{uptimePercent}%
+
{(uptime && `${uptime}%`) || 'Unavailable'}
diff --git a/src/v2/components/TourDeSol/index.jsx b/src/v2/components/TourDeSol/index.jsx index 7c0ea8eb..f4536e92 100644 --- a/src/v2/components/TourDeSol/index.jsx +++ b/src/v2/components/TourDeSol/index.jsx @@ -71,7 +71,10 @@ const TourDeSol = ({ - +