// Copyright 2017-2025 @pezkuwi/app-staking-async authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { PalletStakingStakingLedger } from '@pezkuwi/types/lookup'; import type { BN } from '@pezkuwi/util'; import React, { useState } from 'react'; import { InputBalance, Modal, Static, styled, TxButton } from '@pezkuwi/react-components'; import { useApi } from '@pezkuwi/react-hooks'; import { BlockToTime, FormatBalance } from '@pezkuwi/react-query'; import { BN_ZERO } from '@pezkuwi/util'; import { useTranslation } from '../../translate.js'; import SenderInfo from '../partials/SenderInfo.js'; import useUnbondDuration from '../useUnbondDuration.js'; interface Props { controllerId?: string | null; onClose: () => void; stakingLedger?: PalletStakingStakingLedger; stashId: string; } function Unbond ({ controllerId, onClose, stakingLedger, stashId }: Props): React.ReactElement { const { t } = useTranslation(); const { api } = useApi(); const bondedBlocks = useUnbondDuration(); const [maxBalance] = useState(() => stakingLedger?.active?.unwrap() || null); const [maxUnbond, setMaxUnbond] = useState(); return ( {t('bonded')}} value={maxBalance} /> } maxValue={maxBalance} onChange={setMaxUnbond} withMax /> {bondedBlocks?.gtn(0) && ( )} ); } const StyledModal = styled(Modal)` .staking--Unbond--max > div { justify-content: flex-end; & .column { flex: 0; } } `; export default React.memo(Unbond);