Commit ce7f94f1 authored by Moody Salem's avatar Moody Salem

hide max button appropriately

parent 124b83ae
...@@ -286,14 +286,8 @@ export default function CurrencyInputPanel({ ...@@ -286,14 +286,8 @@ export default function CurrencyInputPanel({
: '-'} : '-'}
</TYPE.body> </TYPE.body>
{showMaxButton && selectedCurrencyBalance ? ( {showMaxButton && selectedCurrencyBalance ? (
<StyledBalanceMax disabled={!showMaxButton} onClick={onMax}> <StyledBalanceMax onClick={onMax}>(Max)</StyledBalanceMax>
(Max) ) : null}
</StyledBalanceMax>
) : (
<StyledBalanceMax disabled={!showMaxButton} onClick={onMax}>
{''}
</StyledBalanceMax>
)}
</RowFixed> </RowFixed>
)} )}
......
...@@ -223,7 +223,7 @@ export default function Swap({ history }: RouteComponentProps) { ...@@ -223,7 +223,7 @@ export default function Swap({ history }: RouteComponentProps) {
}, [approvalState, approvalSubmitted]) }, [approvalState, approvalSubmitted])
const maxInputAmount: CurrencyAmount | undefined = maxAmountSpend(currencyBalances[Field.INPUT]) const maxInputAmount: CurrencyAmount | undefined = maxAmountSpend(currencyBalances[Field.INPUT])
const atMaxInputAmount = Boolean(maxInputAmount && parsedAmounts[Field.INPUT]?.equalTo(maxInputAmount)) const showMaxButton = Boolean(maxInputAmount?.greaterThan(0) && !parsedAmounts[Field.INPUT]?.equalTo(maxInputAmount))
// the callback to execute the swap // the callback to execute the swap
const { callback: swapCallback, error: swapCallbackError } = useSwapCallback( const { callback: swapCallback, error: swapCallbackError } = useSwapCallback(
...@@ -361,7 +361,7 @@ export default function Swap({ history }: RouteComponentProps) { ...@@ -361,7 +361,7 @@ export default function Swap({ history }: RouteComponentProps) {
<CurrencyInputPanel <CurrencyInputPanel
label={independentField === Field.OUTPUT && !showWrap ? 'From (at most)' : 'From'} label={independentField === Field.OUTPUT && !showWrap ? 'From (at most)' : 'From'}
value={formattedAmounts[Field.INPUT]} value={formattedAmounts[Field.INPUT]}
showMaxButton={!atMaxInputAmount} showMaxButton={showMaxButton}
currency={currencies[Field.INPUT]} currency={currencies[Field.INPUT]}
onUserInput={handleTypeInput} onUserInput={handleTypeInput}
onMax={handleMaxInput} onMax={handleMaxInput}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment