Skip to content

Commit

Permalink
fix: CR-832 edit order (#2487)
Browse files Browse the repository at this point in the history
* fix: CR-832 edit order

* fix: invalid input

* chore: add goplus tooltip
  • Loading branch information
viet-nv authored Apr 4, 2024
1 parent 5bef6ba commit 4373893
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/components/swapv2/LimitOrder/EditOrderModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ export default function EditOrderModal({
note={note}
orderInfo={order}
defaultExpire={defaultExpire}
useUrlParams
/>
)}
</Wrapper>
Expand Down
9 changes: 6 additions & 3 deletions src/components/swapv2/LimitOrder/LimitOrderForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,10 @@ const LimitOrderForm = forwardRef<LimitOrderFormHandle, Props>(function LimitOrd
if (currencyIn && activeOrderMakingAmount) {
const value = TokenAmount.fromRawAmount(currencyIn, JSBI.BigInt(activeOrderMakingAmount))
if (isEdit && orderInfo) {
return value.subtract(TokenAmount.fromRawAmount(currencyIn, JSBI.BigInt(orderInfo.makingAmount)))
const makingAmount = TokenAmount.fromRawAmount(currencyIn, JSBI.BigInt(orderInfo.makingAmount))
return value.greaterThan(makingAmount)
? value.subtract(makingAmount)
: TokenAmount.fromRawAmount(currencyIn, 0)
}
return value
}
Expand Down Expand Up @@ -615,11 +618,11 @@ const LimitOrderForm = forwardRef<LimitOrderFormHandle, Props>(function LimitOrd

const autoFillMarketPrice = useRef(false)
useEffect(() => {
if (tradeInfo && !autoFillMarketPrice.current && !loadingTrade) {
if (tradeInfo && !autoFillMarketPrice.current && !loadingTrade && !defaultRate?.rate) {
autoFillMarketPrice.current = true
setPriceRateMarket(true)
}
}, [tradeInfo, setPriceRateMarket, loadingTrade])
}, [tradeInfo, setPriceRateMarket, loadingTrade, defaultRate?.rate])

const trackingTouchInput = useCallback(() => {
mixpanelHandler(MIXPANEL_TYPE.LO_ENTER_DETAIL, 'touch enter amount box')
Expand Down
2 changes: 1 addition & 1 deletion src/components/swapv2/LimitOrder/useValidateInputError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const useValidateInputError = ({
const { setInputValue } = useLimitActionHandlers()
const inputError = useMemo(() => {
try {
if (!inputAmount || !account) return
if (!account) return
if (parseFloat(inputAmount) === 0 && (parseFloat(outputAmount) === 0 || parseFloat(displayRate) === 0)) {
return t`Invalid input amount`
}
Expand Down
10 changes: 9 additions & 1 deletion src/components/swapv2/TokenInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { ReactComponent as SecurityInfoIcon } from 'assets/svg/security_info.svg
import { ReactComponent as ZiczacIcon } from 'assets/svg/ziczac.svg'
import { ButtonEmpty } from 'components/Button'
import CurrencyLogo from 'components/CurrencyLogo'
import { MouseoverTooltip, TextDashed } from 'components/Tooltip'
import MarketInfo from 'components/swapv2/TokenInfo/MarketInfo'
import SecurityInfo from 'components/swapv2/TokenInfo/SecurityInfo'
import { useActiveWeb3React } from 'hooks'
Expand Down Expand Up @@ -158,7 +159,14 @@ const TokenInfoTab = ({ currencies, onBack }: { currencies: { [field in Field]?:
<HeaderPanel>
<LabelHeaderPanel>
<SecurityInfoIcon />
<Trans>Security Info</Trans>

<TextDashed underlineColor={theme.text}>
<MouseoverTooltip
text={t`Token security info provided by Goplus. Please conduct your own research before trading`}
>
<Trans>Security Info</Trans>
</MouseoverTooltip>
</TextDashed>
</LabelHeaderPanel>
<PoweredByWrapper>
<PoweredByText>
Expand Down

0 comments on commit 4373893

Please sign in to comment.