Skip to content

Commit

Permalink
feat(webapp): add yearly rewards and fix infinite skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
Torresmorah committed Feb 8, 2023
1 parent 5e9fdf9 commit 50337c6
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 34 deletions.
20 changes: 16 additions & 4 deletions webapp/src/components/NonCompliantCard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ const NonCompliantCard = ({ producer, stats }) => {
>
{t('bpJson')}:
</Typography>
<VisitSite
title={t('openLink')}
url={producer.bp_json_url}
/>
<VisitSite title={t('openLink')} url={producer.bp_json_url} />
</div>
)}
<RowInfo
Expand All @@ -115,6 +112,21 @@ const NonCompliantCard = ({ producer, stats }) => {
title={`${t('rewards')} (${eosConfig.tokenSymbol})`}
value={`${formatWithThousandSeparator(producer.total_rewards, 0)}`}
/>
<Typography variant="overline">{t('yearlyRewards')}</Typography>
<RowInfo
title={`${t('rewards')} (USD)`}
value={`$${formatWithThousandSeparator(
producer.total_rewards * 365 * stats.tokenPrice,
0,
)}`}
/>
<RowInfo
title={`${t('rewards')} (${eosConfig.tokenSymbol})`}
value={`${formatWithThousandSeparator(
producer.total_rewards * 365,
0,
)}`}
/>
</div>
</>
)
Expand Down
1 change: 1 addition & 0 deletions webapp/src/hooks/customHooks/useNonCompliantState.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const useNonCompliantState = () => {
setStats({
percentageRewards,
dailyRewards: nonCompliantRewards,
yearlyRewards: nonCompliantRewards * 365,
tokenPrice: setting?.token_price,
quantity: nonCompliantBPs.length,
})
Expand Down
2 changes: 2 additions & 0 deletions webapp/src/language/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
"blockProducersRoute": {},
"rewardsDistributionRoute": {
"dailyRewards": "Total Daily Rewards",
"yearlyRewards": "Total Yearly Rewards",
"topCountryDailyRwards": "Top Country By Daily Rewards",
"notAvailable": "Not available",
"paidProducers": "Paid BPs Not Located",
Expand Down Expand Up @@ -262,6 +263,7 @@
"lastClaimTime": "Last Claimed Time",
"noInfo": "No info provided",
"dailyRewards": "Daily Rewards",
"yearlyRewards": "Yearly Rewards",
"invalidUrl": "Invalid URL",
"viewList": "View undiscoverable BPs list",
"bpJson": "BP.json",
Expand Down
2 changes: 2 additions & 0 deletions webapp/src/language/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
"blockProducersRoute": {},
"rewardsDistributionRoute": {
"dailyRewards": "Recompensas Diarias Totales",
"yearlyRewards": "Recompensas Anuales Totales",
"topCountryDailyRwards": "País Superior Por Recompensas Diarias",
"notAvailable": "No Disponible",
"paidProducers": "Productores Pagados No Ubicados",
Expand Down Expand Up @@ -269,6 +270,7 @@
"lastClaimTime": "Último reclamo",
"noInfo": "No provee información",
"dailyRewards": "Recompensas diarias",
"yearlyRewards": "Recompensas anuales",
"invalidUrl": "URL inválida",
"viewList": "Ver lista de BPs indetectables",
"bpJson": "BP.json",
Expand Down
43 changes: 29 additions & 14 deletions webapp/src/routes/NonCompliantBPs/RewardsStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,42 @@ const RewardsStats = ({ stats }) => {
</div>
<div className={`${classes.cardHeader} ${classes.cardShadow}`}>
<div className={classes.rewardsCards}>
<Typography variant="h6" component="h4">{`${t(
'dailyRewards',
)} (USD)`}</Typography>
<Typography variant="h3" component="p" className={classes.statsText}>
{`${formatWithThousandSeparator(
stats.dailyRewards * stats.tokenPrice,
0,
)} USD`}
<Typography variant="h6" component="h4">
{t('dailyRewards')}
</Typography>
<div className={classes.statsText}>
<Typography variant="h3" component="p" className={classes.price}>
{`${formatWithThousandSeparator(stats.dailyRewards, 0)} ${
eosConfig.tokenSymbol
}`}
</Typography>
<Typography variant="h3" component="p" className={classes.price}>
{`$ ${formatWithThousandSeparator(
stats.dailyRewards * stats.tokenPrice,
0,
)} USD`}
</Typography>
</div>
</div>
</div>
<div className={`${classes.cardHeader} ${classes.cardShadow}`}>
<div className={classes.rewardsCards}>
<Typography variant="h6" component="h4">
{`${t('dailyRewards')} (${eosConfig.tokenSymbol})`}
</Typography>
<Typography variant="h3" component="p" className={classes.statsText}>
{`${formatWithThousandSeparator(stats.dailyRewards, 0)} ${
eosConfig.tokenSymbol
}`}
{t('dailyRewards')}
</Typography>
<div className={classes.statsText}>
<Typography variant="h3" component="p" className={classes.price}>
{`${formatWithThousandSeparator(stats.yearlyRewards, 0)} ${
eosConfig.tokenSymbol
}`}
</Typography>
<Typography variant="h3" component="p" className={classes.price}>
{`$ ${formatWithThousandSeparator(
stats.yearlyRewards * stats.tokenPrice,
0,
)} USD`}
</Typography>
</div>
</div>
</div>
<div className={`${classes.cardHeader} ${classes.cardShadow}`}>
Expand Down
5 changes: 4 additions & 1 deletion webapp/src/routes/NonCompliantBPs/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ export default (theme) => ({
},
statsText: {
textAlign: 'center',
marginTop: `${theme.spacing(6)} !important`,
marginTop: `${theme.spacing(4)} !important`,
},
price: {
paddingBottom: theme.spacing(2),
},
statsContainer: {
display: 'flex',
Expand Down
28 changes: 13 additions & 15 deletions webapp/src/routes/RewardsDistribution/RewardsDistributionStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ const useStyles = makeStyles((theme) =>
styles(theme, lowestRewardsColor, highestRewardsColor),
)

const RewardsDistributionStats = ({
summary,
setting,
handlePopoverOpen,
}) => {
const RewardsDistributionStats = ({ summary, setting, handlePopoverOpen }) => {
const classes = useStyles()
const { t } = useTranslation('rewardsDistributionRoute')

Expand Down Expand Up @@ -130,27 +126,29 @@ const RewardsDistributionStats = ({
)}
</div>
<Typography variant="h3" component="p">
{!summary?.producersWithoutProperBpJson.quantity > 0 && (
{!summary?.producersWithoutProperBpJson.quantity > 0 ?? (
<Skeleton variant="text" width="100%" animation="wave" />
)}
{summary?.producersWithoutProperBpJson.quantity > 0 &&
{summary?.producersWithoutProperBpJson.quantity >= 0 &&
summary?.producersWithoutProperBpJson.quantity && (
<span>{summary?.producersWithoutProperBpJson.quantity}</span>
)}
</Typography>
<Typography
variant="subtitle2"
component="p"
className={`${classes.textMargin} ${classes.marginPaidText}`}
>
{t('paidProducersText')}
</Typography>
{summary?.producersWithoutProperBpJson.rewards > 0 && (
<Typography
variant="subtitle2"
component="p"
className={`${classes.textMargin} ${classes.marginPaidText}`}
>
{t('paidProducersText')}
</Typography>
)}
<Typography
variant="subtitle1"
component="p"
className={classes.textMargin}
>
{!summary?.producersWithoutProperBpJson.rewards > 0 && (
{!summary?.producersWithoutProperBpJson.rewards > 0 ?? (
<Skeleton variant="text" width="100%" animation="wave" />
)}
{summary?.producersWithoutProperBpJson.rewards > 0 && (
Expand Down

0 comments on commit 50337c6

Please sign in to comment.