From b9506fabe6f97f6523d905482a548c9b7c51fc83 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 11 Feb 2021 12:32:00 +0100 Subject: [PATCH] Adjust summary for bounty-specific (UI-like countdown, total bounty summary) (#4652) --- packages/page-bounties/src/Summary.tsx | 57 +++++++++++--------------- 1 file changed, 23 insertions(+), 34 deletions(-) diff --git a/packages/page-bounties/src/Summary.tsx b/packages/page-bounties/src/Summary.tsx index afd3f3d2f4..4edf77ff07 100644 --- a/packages/page-bounties/src/Summary.tsx +++ b/packages/page-bounties/src/Summary.tsx @@ -1,12 +1,12 @@ // Copyright 2017-2020 @polkadot/app-bounties authors & contributors // SPDX-License-Identifier: Apache-2.0 -import React from 'react'; +import BN from 'bn.js'; +import React, { useMemo } from 'react'; import { CardSummary, SummaryBox } from '@polkadot/react-components'; -import Progress from '@polkadot/react-components/Progress'; import { useTreasury } from '@polkadot/react-hooks'; -import { BlockToTime, FormatBalance } from '@polkadot/react-query'; +import { FormatBalance } from '@polkadot/react-query'; import { useBounties } from './hooks'; import { useTranslation } from './translate'; @@ -18,9 +18,13 @@ interface Props { function Summary ({ activeBounties, className = '' }: Props): React.ReactElement { const { t } = useTranslation(); - const { bestNumber, bountyIndex } = useBounties(); + const { bestNumber, bounties, bountyIndex } = useBounties(); + const { spendPeriod } = useTreasury(); - const { spendPeriod, value } = useTreasury(); + const totalValue = useMemo( + () => (bounties || []).reduce((total, { bounty: { value } }) => total.iadd(value), new BN(0)), + [bounties] + ); return ( @@ -35,37 +39,22 @@ function Summary ({ activeBounties, className = '' }: Props): React.ReactElement )}
- {value && ( - ('treasury')}> - - - )} + ('active total')}> + + +
+
{bestNumber && spendPeriod.gtn(0) && ( - ('next bounty funding in')}> - - - )} - {spendPeriod.gtn(0) && ( ('spend period')} - > - - - )} - {bestNumber && spendPeriod.gtn(0) && ( - ('funding period')} + progress={{ + total: spendPeriod, + value: bestNumber.mod(spendPeriod), + withTime: true + }} /> )}