Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip the first token allowance screen if dapp proposing spending cap is 0 #16502

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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