diff --git a/packages/page-treasury/src/Overview/Tip.tsx b/packages/page-treasury/src/Overview/Tip.tsx index 686668979e..8ef0c64a36 100644 --- a/packages/page-treasury/src/Overview/Tip.tsx +++ b/packages/page-treasury/src/Overview/Tip.tsx @@ -4,9 +4,9 @@ import { OpenTip } from '@polkadot/types/interfaces'; -import React from 'react'; -import { AddressSmall, AddressMini, Expander } from '@polkadot/react-components'; -import { useApi, useCall } from '@polkadot/react-hooks'; +import React, { useEffect, useState } from 'react'; +import { AddressSmall, AddressMini, Badge, Expander, Icon } from '@polkadot/react-components'; +import { useAccounts, useApi, useCall } from '@polkadot/react-hooks'; import { FormatBalance } from '@polkadot/react-query'; import { Option } from '@polkadot/types'; @@ -24,10 +24,18 @@ interface Props { function Tip ({ className = '', hash, isMember, members }: Props): React.ReactElement | null { const { t } = useTranslation(); const { api } = useApi(); + const { allAccounts } = useAccounts(); + const [isTipper, setIsTipper] = useState(false); const tip = useCall(api.query.treasury.tips, [hash], { transform: (optTip: Option) => optTip.unwrapOr(null) }); + useEffect((): void => { + tip && setIsTipper( + tip.tips.some(([address]) => allAccounts.includes(address.toString())) + ); + }, [allAccounts, tip]); + if (!tip) { return null; } @@ -71,6 +79,13 @@ function Tip ({ className = '', hash, isMember, members }: Props): React.ReactEl isMember={isMember} members={members} /> + {isMember && ( + } + isInline + type={isTipper ? 'green' : 'gray'} + /> + )} );