diff --git a/packages/page-bounties/src/Bounty.tsx b/packages/page-bounties/src/Bounty.tsx index 714453401f..670bde0907 100644 --- a/packages/page-bounties/src/Bounty.tsx +++ b/packages/page-bounties/src/Bounty.tsx @@ -4,14 +4,12 @@ import type { DeriveCollectiveProposal } from '@polkadot/api-derive/types'; import type { BlockNumber, Bounty as BountyType, BountyIndex } from '@polkadot/types/interfaces'; -import BN from 'bn.js'; import React, { useCallback, useMemo, useState } from 'react'; import styled from 'styled-components'; import { AddressSmall, Icon, LinkExternal } from '@polkadot/react-components'; import { ThemeProps } from '@polkadot/react-components/types'; -import { BlockToTime, FormatBalance } from '@polkadot/react-query'; -import { formatNumber } from '@polkadot/util'; +import { FormatBalance } from '@polkadot/react-query'; import BountyActionMessage from './BountyNextActionInfo/BountyActionMessage'; import { getProposalToDisplay } from './helpers/extendedStatuses'; @@ -20,6 +18,7 @@ import BountyExtraActions from './BountyExtraActions'; import BountyInfos from './BountyInfos'; import BountyStatusView from './BountyStatusView'; import Curator from './Curator'; +import DueBlocks from './DueBlocks'; import { useBountyStatus } from './hooks'; import { bountyBorderColor, bountyLabelColor } from './theme'; import { useTranslation } from './translate'; @@ -34,11 +33,6 @@ interface Props { proposals?: DeriveCollectiveProposal[]; } -interface DueProps { - dueBlocks: BN | undefined; - until: 'update' | 'payout'; -} - const EMPTY_CELL = '-'; function Bounty ({ bestNumber, bounty, className = '', description, index, proposals }: Props): React.ReactElement { @@ -93,18 +87,20 @@ function Bounty ({ bestNumber, bounty, className = '', description, index, propo )} - {blocksUntilPayout - ? ('payout')} /> - : ''} - {blocksUntilUpdate - ? ('update')} /> - : ''} + )} { - const { t } = useTranslation(); - - return ( - <> - {dueBlocks && dueBlocks.gtn(0) && ( - <> - {t('{{blocks}} blocks', { replace: { blocks: formatNumber(dueBlocks) } })} - until {until} - - )} - - ); -} - export default React.memo(styled(Bounty)(({ theme }: ThemeProps) => ` .description-column { max-width: 200px; diff --git a/packages/page-bounties/src/DueBlocks.tsx b/packages/page-bounties/src/DueBlocks.tsx new file mode 100644 index 0000000000..a46162a9f7 --- /dev/null +++ b/packages/page-bounties/src/DueBlocks.tsx @@ -0,0 +1,31 @@ +// Copyright 2017-2021 @polkadot/app-bounties authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import BN from 'bn.js'; +import React from 'react'; + +import { BlockToTime } from '@polkadot/react-query'; +import { formatNumber } from '@polkadot/util'; + +interface Props { + dueBlocks: BN; + endBlock: BN; + label: string; +} + +function DueBlocks ({ dueBlocks, endBlock, label }: Props): React.ReactElement { + return ( + <> + {dueBlocks.gtn(0) && ( + <> + +  ({label}) + + #{formatNumber(endBlock)} + + )} + + ); +} + +export default React.memo(DueBlocks);