// Copyright 2017-2023 @polkadot/app-treasury authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { DeriveTreasuryProposal } from '@polkadot/api-derive/types'; import React, { useMemo } from 'react'; import { AddressSmall, Columar, LinkExternal, Table } from '@polkadot/react-components'; import { useApi, useToggle } from '@polkadot/react-hooks'; import { FormatBalance } from '@polkadot/react-query'; import { isFunction } from '@polkadot/util'; import { useTranslation } from '../translate'; import Council from './Council'; interface Props { className?: string; isMember: boolean; members: string[]; proposal: DeriveTreasuryProposal; withSend: boolean; } function ProposalDisplay ({ className = '', isMember, members, proposal: { council, id, proposal }, withSend }: Props): React.ReactElement { const { t } = useTranslation(); const { api } = useApi(); const [isExpanded, toggleIsExpanded] = useToggle(false); const hasCouncil = isFunction(api.tx.council?.propose); const hasProposals = useMemo( () => !!council .map(({ votes }) => votes ? votes.index.toNumber() : -1) .filter((index) => index !== -1) .length, [council] ); return ( <> {hasCouncil ? hasProposals ? {t('Voting')} : withSend && ( ) : null } ); } export default React.memo(ProposalDisplay);