From f7cb1844d60bbc7da4dfe41daa8733dac55e02b2 Mon Sep 17 00:00:00 2001 From: Adnan Sahovic <63151811+adnansahovic@users.noreply.github.com> Date: Thu, 17 Nov 2022 15:12:44 +0100 Subject: [PATCH] Skip the first token allowance screen if dapp proposing spending cap is 0 (#16502) --- ui/pages/token-allowance/token-allowance.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ui/pages/token-allowance/token-allowance.js b/ui/pages/token-allowance/token-allowance.js index 4d02f788e..83bd4f29c 100644 --- a/ui/pages/token-allowance/token-allowance.js +++ b/ui/pages/token-allowance/token-allowance.js @@ -76,7 +76,9 @@ export default function TokenAllowance({ const [showContractDetails, setShowContractDetails] = useState(false); const [showFullTxDetails, setShowFullTxDetails] = useState(false); - const [isFirstPage, setIsFirstPage] = useState(true); + const [isFirstPage, setIsFirstPage] = useState( + dappProposedTokenAmount !== '0', + ); const [errorText, setErrorText] = useState(''); const currentAccount = useSelector(getCurrentAccountWithSendEtherInfo); @@ -181,6 +183,8 @@ export default function TokenAllowance({ setIsFirstPage(true); }; + const isEmpty = customTokenAmount === ''; + return ( {isFirstPage && t('setSpendingCap')} {!isFirstPage && - (customTokenAmount === 0 + (customTokenAmount === '0' || isEmpty ? t('revokeSpendingCap') : t('reviewSpendingCap'))} @@ -309,7 +313,11 @@ export default function TokenAllowance({ handleBackClick()} /> )}