// Copyright 2017-2026 @pezkuwi/app-democracy authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { Option } from '@pezkuwi/types'; import type { TreasuryProposal as TreasuryProposalType } from '@pezkuwi/types/interfaces'; import React, { useEffect, useState } from 'react'; import { useApi } from '@pezkuwi/react-hooks'; import { FormatBalance } from '@pezkuwi/react-query'; import InputAddress from './InputAddress/index.js'; import Labelled from './Labelled.js'; import Static from './Static.js'; import { useTranslation } from './translate.js'; interface Props { className?: string; onClick?: () => void; proposalId?: string; proposal?: TreasuryProposalType | null; withLink?: boolean; } function TreasuryProposal ({ className = '', onClick, proposal, proposalId }: Props): React.ReactElement | null { const { t } = useTranslation(); const [stateProposal, setProposal] = useState(null); const { api } = useApi(); useEffect((): void => { if (!proposal && proposalId) { api.query.treasury .proposals>(proposalId) .then((proposal): TreasuryProposalType | null => proposal.unwrapOr(null)) .catch((): null => null) .then(setProposal) .catch(console.error); } else { setProposal(proposal || null); } }, [api, proposal, proposalId]); if (!stateProposal) { return null; } const { beneficiary, bond, proposer, value } = stateProposal; const inner = ( <> ); return (
{inner}
); } export default React.memo(TreasuryProposal);