From d24d2882e4d85f87c2036cccfccf2e4a8871a0b6 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Sun, 28 Jun 2020 21:23:33 +0200 Subject: [PATCH] Don't allow re-{validate, nominate} with active 0 (#3080) --- packages/page-staking/src/Actions/Account/index.tsx | 13 ++++++++++--- packages/react-components/src/AddressInfo.tsx | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/page-staking/src/Actions/Account/index.tsx b/packages/page-staking/src/Actions/Account/index.tsx index 35c25638a6..ba611c4c9a 100644 --- a/packages/page-staking/src/Actions/Account/index.tsx +++ b/packages/page-staking/src/Actions/Account/index.tsx @@ -7,7 +7,7 @@ import { EraIndex } from '@polkadot/types/interfaces'; import { StakerState } from '@polkadot/react-hooks/types'; import { SortedTargets } from '../../types'; -import React from 'react'; +import React, { useEffect, useState } from 'react'; import styled from 'styled-components'; import { AddressInfo, AddressMini, AddressSmall, Button, Menu, Popup, StakingBonded, StakingRedeemable, StakingUnbonding, TxButton } from '@polkadot/react-components'; import { useApi, useCall, useToggle } from '@polkadot/react-hooks'; @@ -48,6 +48,13 @@ function Account ({ className = '', info: { controllerId, destination, destinati const [isSettingsOpen, toggleSettings] = useToggle(); const [isUnbondOpen, toggleUnbond] = useToggle(); const [isValidateOpen, toggleValidate] = useToggle(); + const [hasBonded, setHasBonded] = useState(false); + + useEffect((): void => { + stakingAccount?.stakingLedger && setHasBonded( + !stakingAccount.stakingLedger.active.isEmpty + ); + }, [stakingAccount]); return ( @@ -176,7 +183,7 @@ function Account ({ className = '', info: { controllerId, destination, destinati : (