diff --git a/packages/page-treasury/src/Overview/Tip.tsx b/packages/page-treasury/src/Overview/Tip.tsx index 8ef0c64a36..05c2e89c01 100644 --- a/packages/page-treasury/src/Overview/Tip.tsx +++ b/packages/page-treasury/src/Overview/Tip.tsx @@ -2,26 +2,29 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { OpenTip } from '@polkadot/types/interfaces'; +import { BlockNumber, OpenTip } from '@polkadot/types/interfaces'; import React, { useEffect, useState } from 'react'; -import { AddressSmall, AddressMini, Badge, Expander, Icon } from '@polkadot/react-components'; +import { AddressSmall, AddressMini, Expander, Icon } from '@polkadot/react-components'; import { useAccounts, useApi, useCall } from '@polkadot/react-hooks'; -import { FormatBalance } from '@polkadot/react-query'; +import { BlockToTime, FormatBalance } from '@polkadot/react-query'; import { Option } from '@polkadot/types'; +import { formatNumber } from '@polkadot/util'; import { useTranslation } from '../translate'; +import TipClose from './TipClose'; import TipEndorse from './TipEndorse'; import TipReason from './TipReason'; interface Props { + bestNumber?: BlockNumber; className?: string; hash: string; isMember: boolean; members: string[]; } -function Tip ({ className = '', hash, isMember, members }: Props): React.ReactElement | null { +function Tip ({ bestNumber, className = '', hash, isMember, members }: Props): React.ReactElement | null { const { t } = useTranslation(); const { api } = useApi(); const { allAccounts } = useAccounts(); @@ -40,8 +43,9 @@ function Tip ({ className = '', hash, isMember, members }: Props): React.ReactEl return null; } - const { finder, reason, tips, who } = tip; + const { closes, finder, reason, tips, who } = tip; const finderInfo = finder.unwrapOr(null); + const closesAt = closes.unwrapOr(null); return ( @@ -74,18 +78,34 @@ function Tip ({ className = '', hash, isMember, members }: Props): React.ReactEl )} - - {isMember && ( - } - isInline - type={isTipper ? 'green' : 'gray'} + {!closesAt && ( + )} + {bestNumber && closesAt && ( + closesAt.gt(bestNumber) + ? ( + <> + + #{formatNumber(closesAt)} + + ) + : ( + + ) + )} + + + {isMember && isTipper && ( + + )} ); diff --git a/packages/page-treasury/src/Overview/TipClose.tsx b/packages/page-treasury/src/Overview/TipClose.tsx new file mode 100644 index 0000000000..d84955b1ca --- /dev/null +++ b/packages/page-treasury/src/Overview/TipClose.tsx @@ -0,0 +1,68 @@ +// Copyright 2017-2020 @polkadot/app-treasury authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +import React, { useState } from 'react'; +import { Button, InputAddress, Modal, TxButton } from '@polkadot/react-components'; +import { useToggle } from '@polkadot/react-hooks'; + +import { useTranslation } from '../translate'; + +interface Props { + hash: string; + isMember: boolean; + members: string[]; +} + +function TipClose ({ hash, isMember, members }: Props): React.ReactElement { + const { t } = useTranslation(); + const [isOpen, toggleOpen] = useToggle(); + const [accountId, setAccountId] = useState(null); + + return ( + <> +