Skip to content

Commit

Permalink
chore: fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
khanti42 committed Jan 30, 2025
1 parent 27e6621 commit b3d8b17
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 49 deletions.
3 changes: 3 additions & 0 deletions packages/wallet-ui/src/assets/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
"amount": {
"message": "Amount"
},
"back": {
"message": "Back"
},
"cancel": {
"message": "CANCEL"
},
Expand Down
3 changes: 3 additions & 0 deletions packages/wallet-ui/src/assets/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
"amount": {
"message": "Montant"
},
"back": {
"message": "Retour"
},
"cancel": {
"message": "ANNULER"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export const MaxButton = styled(Button).attrs((props) => ({
export const Input = styled.input<IInput>`
border: none;
height: 50px;
width: 8px;
font-size: ${(props) => props.theme.typography.p2.fontSize};
font-family: ${(props) => props.theme.typography.p2.fontFamily};
color: ${(props) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,6 @@ export const AmountInputView = ({
const [totalPrice, setTotalPrice] = useState('');
const [usdMode, setUsdMode] = useState(false);

const fetchTotalPrice = useCallback(() => {
if (asset.usdPrice && inputValue && inputValue !== '.') {
const inputFloat = parseFloat(inputValue);
setTotalPrice(getAmountPrice(asset, inputFloat, usdMode));
} else {
setTotalPrice('');
}
}, [asset, inputValue, usdMode]);

const resizeInput = useCallback(() => {
if (inputRef.current !== null) {
inputRef.current.style.width = inputValue.length * 8 + 6 + 'px';
}
}, [inputValue]);

const triggerOnChange = (newValue: string) => {
setInputValue(newValue);
if (onChangeCustom) {
Expand All @@ -72,8 +57,11 @@ export const AmountInputView = ({

useEffect(() => {
// Adjust the input size whenever the value changes
resizeInput();
}, [resizeInput]);
if (inputRef.current !== null) {
inputRef.current.style.width = inputValue.length * 8 + 6 + 'px';
}
}, [inputValue]);

const handleOnKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
//Only accept numeric and decimals
if (
Expand Down Expand Up @@ -103,29 +91,24 @@ export const AmountInputView = ({
};

const handleMaxClick = () => {
if (value && asset.usdPrice) {
const amountStr = ethers.utils
.formatUnits(asset.amount, asset.decimals)
.toString();
const amountFloat = parseFloat(amountStr);
const value = usdMode
? getAmountPrice(asset, amountFloat, false)
: amountStr;
fetchTotalPrice();
resizeInput();
triggerOnChange(value);
}
const amountStr = ethers.utils
.formatUnits(asset.amount, asset.decimals)
.toString();
const amountFloat = parseFloat(amountStr);
const value = usdMode
? getAmountPrice(asset, amountFloat, false)
: amountStr;
triggerOnChange(value);
};

useEffect(() => {
if (value !== undefined) {
setInputValue(value);
if (asset.usdPrice && inputValue && inputValue !== '.') {
const inputFloat = parseFloat(inputValue);
setTotalPrice(getAmountPrice(asset, inputFloat, usdMode));
} else {
setTotalPrice('');
}
}, [value]);

useEffect(() => {
fetchTotalPrice();
}, [fetchTotalPrice]);
}, [asset, inputValue, usdMode]);

return (
<Wrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,8 @@ export const SendModalView = ({ closeModal }: Props) => {
const debounceRef = useRef<NodeJS.Timeout | null>(null);
const [loading, setLoading] = useState(false);

useEffect(() => {}, [fields]);

const handleBack = (amount: string, address: string) => {
const handleBack = () => {
setSummaryModalOpen(false);

setFields((prevFields) => ({
...prevFields,
amount: amount,
address: address,
}));
};

const handleChange = (fieldName: string, fieldValue: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ interface Props {
amount: string;
chainId: string;
closeModal?: () => void;
handleBack: (amount: string, address: string) => void;
handleBack: () => void;
selectedFeeToken: FeeToken;
}

Expand Down Expand Up @@ -321,11 +321,11 @@ export const SendSummaryModalView = ({
</Wrapper>
<Buttons>
<ButtonStyled
onClick={() => handleBack(amount, address)}
onClick={() => handleBack()}
backgroundTransparent
borderVisible
>
{translate('reject').toUpperCase()}
{translate('back').toUpperCase()}
</ButtonStyled>
<ButtonStyled
enabled={!estimatingGas && !gasFeesError && !totalExceedsBalance}
Expand Down

0 comments on commit b3d8b17

Please sign in to comment.