Skip to content

Commit

Permalink
Edit copy
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronfigueiredo committed Oct 8, 2024
1 parent c5541a2 commit a62e734
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TransactionMeta } from '@metamask/transaction-controller';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import React, { useCallback, useEffect, useState } from 'react';
import { useDispatch } from 'react-redux';
import { calcTokenAmount } from '../../../../../../../../shared/lib/transactions-controller-utils';
import { hexToDecimal } from '../../../../../../../../shared/modules/conversion.utils';
Expand Down Expand Up @@ -128,17 +128,14 @@ export const EditSpendingCapModal = ({
setCustomSpendingCapInputValue(formattedSpendingCap.toString());
}, [customSpendingCapInputValue, formattedSpendingCap]);

const showDecimalError = useMemo(() => {
return (
decimals &&
parseInt(decimals, 10) < countDecimalDigits(customSpendingCapInputValue)
);
}, [decimals, customSpendingCapInputValue]);
const showDecimalError =
decimals &&
parseInt(decimals, 10) < countDecimalDigits(customSpendingCapInputValue);

return (
<Modal
isOpen={isOpenEditSpendingCapModal}
onClose={() => handleCancel()}
onClose={handleCancel}
isClosedOnEscapeKey
isClosedOnOutsideClick
className="edit-spending-cap-modal"
Expand Down Expand Up @@ -173,6 +170,15 @@ export const EditSpendingCapModal = ({
style={{ width: '100%' }}
inputProps={{ 'data-testid': 'custom-spending-cap-input' }}
/>
{showDecimalError && (
<Text
variant={TextVariant.bodySm}
color={TextColor.errorDefault}
paddingTop={1}
>
{t('editSpendingCapError', [decimals])}
</Text>
)}
<Text
variant={TextVariant.bodySm}
color={TextColor.textAlternative}
Expand All @@ -183,15 +189,6 @@ export const EditSpendingCapModal = ({
tokenSymbol || '',
])}
</Text>
{showDecimalError && (
<Text
variant={TextVariant.bodySm}
color={TextColor.errorDefault}
paddingTop={1}
>
{t('editSpendingCapError', [decimals])}
</Text>
)}
</ModalBody>
<ModalFooter
onSubmit={handleSubmit}
Expand Down

0 comments on commit a62e734

Please sign in to comment.