Skip to content

Commit

Permalink
Skip the first token allowance screen if dapp proposing spending cap …
Browse files Browse the repository at this point in the history
…is 0
  • Loading branch information
adnansahovic committed Nov 15, 2022
1 parent dcf79b0 commit c47a3f1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions ui/pages/token-allowance/token-allowance.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -181,6 +183,8 @@ export default function TokenAllowance({
setIsFirstPage(true);
};

const isEmpty = customTokenAmount === '';

return (
<Box className="token-allowance-container page-container">
<Box
Expand Down Expand Up @@ -267,7 +271,7 @@ export default function TokenAllowance({
>
{isFirstPage && t('setSpendingCap')}
{!isFirstPage &&
(customTokenAmount === 0
(customTokenAmount === '0' || isEmpty
? t('revokeSpendingCap')
: t('reviewSpendingCap'))}
</Typography>
Expand Down Expand Up @@ -309,7 +313,11 @@ export default function TokenAllowance({
<ReviewSpendingCap
tokenName={tokenSymbol}
currentTokenBalance={parseFloat(currentTokenBalance)}
tokenValue={parseFloat(customTokenAmount)}
tokenValue={
isNaN(parseFloat(customTokenAmount))
? parseFloat(dappProposedTokenAmount)
: parseFloat(customTokenAmount)
}
onEdit={() => handleBackClick()}
/>
)}
Expand Down

0 comments on commit c47a3f1

Please sign in to comment.