Skip to content

Commit

Permalink
fix: Quick input stays same after amount change
Browse files Browse the repository at this point in the history
  • Loading branch information
memoyil committed Jul 7, 2023
1 parent 09be4f1 commit 24be2af
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
4 changes: 2 additions & 2 deletions apps/aptos/components/CurrencyInputPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ export const CurrencyInputPanel = ({
onPercentInput &&
[25, 50, 75].map((percent) => {
const isAtCurrentPercent =
(maxAmount && value === percentAmount[percent]) || (lpPercent && lpPercent === percent.toString())

(maxAmount && value !== '0' && value === percentAmount[percent]) ||
(lpPercent && lpPercent === percent.toString())
return (
<Button
key={`btn_quickCurrency${percent}`}
Expand Down
12 changes: 3 additions & 9 deletions apps/web/src/components/CurrencyInputPanel/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMemo, useState, memo, useCallback } from 'react'
import { useMemo, memo, useCallback } from 'react'
import { Currency, Pair, Token, Percent, CurrencyAmount } from '@pancakeswap/sdk'
import {
Button,
Expand All @@ -24,7 +24,7 @@ import { StablePair } from 'views/AddLiquidity/AddStableLiquidity/hooks/useStabl

import { FiatLogo } from 'components/Logo/CurrencyLogo'
import { useAccount } from 'wagmi'
import { useCurrencyBalance } from '../../state/wallet/hooks'
import { useCurrencyBalance } from 'state/wallet/hooks'
import CurrencySearchModal from '../SearchModal/CurrencySearchModal'
import { CurrencyLogo, DoubleCurrencyLogo } from '../Logo'

Expand Down Expand Up @@ -160,7 +160,6 @@ const CurrencyInputPanel = memo(function CurrencyInputPanel({
const handleUserInput = useCallback(
(val: string) => {
onUserInput(val)
setCurrentClickedPercent('')
},
[onUserInput],
)
Expand All @@ -171,8 +170,6 @@ const CurrencyInputPanel = memo(function CurrencyInputPanel({
}
}, [onPresentCurrencyModal, disableCurrencySelect])

const [currentClickedPercent, setCurrentClickedPercent] = useState('')

const isAtPercentMax = (maxAmount && value === maxAmount.toExact()) || (lpPercent && lpPercent === '100')

const balance = !hideBalance && !!currency && formatAmount(selectedCurrencyBalance, 6)
Expand Down Expand Up @@ -289,7 +286,6 @@ const CurrencyInputPanel = memo(function CurrencyInputPanel({
showQuickInputButton &&
onPercentInput &&
[25, 50, 75].map((percent) => {
const isAtClickedPercent = currentClickedPercent === percent.toString()
const isAtCurrentPercent =
(maxAmount && value !== '0' && value === percentAmount[percent]) ||
(lpPercent && lpPercent === percent.toString())
Expand All @@ -299,11 +295,10 @@ const CurrencyInputPanel = memo(function CurrencyInputPanel({
key={`btn_quickCurrency${percent}`}
onClick={() => {
onPercentInput(percent)
setCurrentClickedPercent(percent.toString())
}}
scale="xs"
mr="5px"
variant={isAtClickedPercent || isAtCurrentPercent ? 'primary' : 'secondary'}
variant={isAtCurrentPercent ? 'primary' : 'secondary'}
style={{ textTransform: 'uppercase' }}
>
{percent}%
Expand All @@ -316,7 +311,6 @@ const CurrencyInputPanel = memo(function CurrencyInputPanel({
e.stopPropagation()
e.preventDefault()
onMax?.()
setCurrentClickedPercent('MAX')
}}
scale="xs"
variant={isAtPercentMax ? 'primary' : 'secondary'}
Expand Down

0 comments on commit 24be2af

Please sign in to comment.