diff --git a/src/pages/Staking/AuthorizeStakingApps/index.tsx b/src/pages/Staking/AuthorizeStakingApps/index.tsx index 2f3ef6386..eaf1f30ac 100644 --- a/src/pages/Staking/AuthorizeStakingApps/index.tsx +++ b/src/pages/Staking/AuthorizeStakingApps/index.tsx @@ -83,10 +83,6 @@ const AuthorizeStakingAppsPage: FC = () => { dispatch(stakingApplicationsSlice.actions.getSupportedApps({})) }, [dispatch, account]) - const tbtcMinAuthAmount = useStakingAppMinAuthorizationAmount("tbtc") - const randomBeaconMinAuthAmount = - useStakingAppMinAuthorizationAmount("randomBeacon") - const tbtcApp = useStakingAppDataByStakingProvider( "tbtc", stakingProviderAddress || AddressZero @@ -96,17 +92,6 @@ const AuthorizeStakingAppsPage: FC = () => { stakingProviderAddress || AddressZero ) - const stake = useSelector((state: RootState) => - selectStakeByStakingProvider(state, stakingProviderAddress!) - ) as StakeData - - const isLoggedInAsAuthorizer = - stake && account ? isSameETHAddress(stake.authorizer, account) : false - - const isInactiveStake = stake - ? BigNumber.from(stake?.totalInTStake).isZero() - : false - const appsAuthData: { [appName: string]: AppAuthDataProps & { address?: string } } = { @@ -130,6 +115,37 @@ const AuthorizeStakingAppsPage: FC = () => { }, } + useEffect(() => { + if (tbtcApp.isAuthorized) { + setSelectedApps((selectedApps) => + selectedApps.filter(({ stakingAppId }) => stakingAppId !== "tbtc") + ) + } + + if (randomBeaconApp.isAuthorized) { + setSelectedApps((selectedApps) => + selectedApps.filter( + ({ stakingAppId }) => stakingAppId !== "randomBeacon" + ) + ) + } + }, [tbtcApp.isAuthorized, randomBeaconApp.isAuthorized]) + + const tbtcMinAuthAmount = useStakingAppMinAuthorizationAmount("tbtc") + const randomBeaconMinAuthAmount = + useStakingAppMinAuthorizationAmount("randomBeacon") + + const stake = useSelector((state: RootState) => + selectStakeByStakingProvider(state, stakingProviderAddress!) + ) as StakeData + + const isLoggedInAsAuthorizer = + stake && account ? isSameETHAddress(stake.authorizer, account) : false + + const isInactiveStake = stake + ? BigNumber.from(stake?.totalInTStake).isZero() + : false + const isAppSelected = (stakingAppName: AppAuthDataProps["stakingAppId"]) => { return selectedApps.map((app) => app.stakingAppId).includes(stakingAppName) } @@ -275,15 +291,17 @@ const AuthorizeStakingAppsPage: FC = () => { /> )} - + {(!tbtcApp.isAuthorized || !randomBeaconApp.isAuthorized) && ( + + )} ) : (