Skip to content

Commit

Permalink
show max button handled for add liquidity
Browse files Browse the repository at this point in the history
  • Loading branch information
vnaysngh-mudrex committed Dec 29, 2023
1 parent d738b31 commit 8d0dfc4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 9 additions & 5 deletions src/components/CurrencyInputPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ export default function CurrencyInputPanel({
}: CurrencyInputPanelProps) {
const [modalOpen, setModalOpen] = useState(false)
const { address: account, chainId } = useAccountDetails()
const selectedCurrencyBalance = useCurrencyBalance(account ?? undefined, currency ?? undefined)
const { formatted } = useAccountBalance(currency as Currency)
const { formatted, balance } = useAccountBalance(currency as Currency)
const theme = useTheme()

const handleDismissSearch = useCallback(() => {
Expand All @@ -224,7 +223,12 @@ export default function CurrencyInputPanel({

const chainAllowed = isSupportedChain(chainId)

const handleMaxAmount = () => {
if (balance) onUserInput(balance)
}

const containerStyles = hideShadow ? { boxShadow: 'none' } : {}
const showMax = balance !== null && Number(value) !== Number(balance)
return (
<InputPanel id={id} hideInput={hideInput} {...rest}>
{!locked && (
Expand Down Expand Up @@ -290,13 +294,13 @@ export default function CurrencyInputPanel({
<RowBetween>
{account && (
<RowFixed style={{ height: '17px' }}>
{Boolean(showMaxButton && selectedCurrencyBalance) && (
<StyledBalanceMax onClick={onMax}>
{showMax && formatted && (
<StyledBalanceMax onClick={handleMaxAmount}>
<Trans>MAX</Trans>
</StyledBalanceMax>
)}
<ThemedText.DeprecatedBody
onClick={onMax}
onClick={handleMaxAmount}
color={theme.neutral3}
fontWeight={535}
fontSize={14}
Expand Down
3 changes: 1 addition & 2 deletions src/pages/AddLiquidity/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,7 @@ function AddLiquidity() {
disabled={!isValid}
error={!isValid && !!parsedAmounts[Field.CURRENCY_A] && !!parsedAmounts[Field.CURRENCY_B]}
>
{/* <Text fontWeight={535}>{errorMessage || <Trans>Preview</Trans>}</Text> */}
<Text fontWeight={535}>{<Trans>Preview</Trans>}</Text>
<Text fontWeight={535}>{errorMessage ? errorMessage : <Trans>Preview</Trans>}</Text>
</ButtonError>
</AutoColumn>
)
Expand Down

0 comments on commit 8d0dfc4

Please sign in to comment.