// Copyright 2017-2025 @polkadot/app-staking-async authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { BN } from '@polkadot/util'; import React, { useRef, useState } from 'react'; import useAmountError from '@polkadot/app-staking2/Pools/useAmountError'; import { Dropdown, InputBalance, Modal, TxButton } from '@polkadot/react-components'; import { useApi } from '@polkadot/react-hooks'; import { BalanceFree } from '@polkadot/react-query'; import { BN_ZERO } from '@polkadot/util'; import { useTranslation } from '../../translate.js'; import PoolInfo from '../partials/PoolInfo.js'; interface Props { className?: string; controllerId: string; onClose: () => void; poolId: BN; } const DEFAULT_TYPE = 'rewards'; function BondExtra ({ className, controllerId, onClose, poolId }: Props): React.ReactElement { const { t } = useTranslation(); const { api } = useApi(); const [type, setType] = useState(DEFAULT_TYPE); const [amount, setAmount] = useState(); const isAmountError = useAmountError(controllerId, amount, BN_ZERO); const typeRef = useRef([ { text: t('Free balance'), value: 'free' }, { text: t('Pool rewards'), value: 'rewards' } ]); return ( {type === 'free' && ( {t('balance')}} params={controllerId} /> } onChange={setAmount} /> )} ); } export default React.memo(BondExtra);