Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Commit

Permalink
Allow to specify empty number of hops
Browse files Browse the repository at this point in the history
  • Loading branch information
anxolin committed Nov 16, 2020
1 parent e3565c5 commit 807d3dc
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/pages/OrderBook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,19 @@ const OrderBook: React.FC = () => {
const { tokens: tokenList } = useTokenList({ networkId: networkIdOrDefault })
const [baseToken, setBaseToken] = useSafeState<TokenDetails | null>(null)
const [quoteToken, setQuoteToken] = useSafeState<TokenDetails | null>(null)
const [hops, setHops] = useSafeState()
const [batchId, setBatchId] = useSafeState<number | undefined>(undefined)
const [hopsValue, setHopsValue] = useSafeState('')
const hops = useMemo(() => {
if (hopsValue) {
const parsedHops = Number(hopsValue)

if (!Number.isNaN(parsedHops)) {
return parsedHops
}
}

return undefined
}, [hopsValue])

const tokensLoaded = tokenList.length !== 0
useEffect(() => {
Expand Down Expand Up @@ -132,16 +143,11 @@ const OrderBook: React.FC = () => {
<InputBox>
<label>Hops</label>
<Input
value={hops}
value={hopsValue}
type="number"
min="0"
max={ORDER_BOOK_HOPS_MAX.toString()}
onChange={(e: ChangeEvent<HTMLInputElement>): void => {
const hopsValue = e.target.value
if (hopsValue && !Number.isNaN(Number(hopsValue))) {
setHops(Number(hopsValue))
}
}}
onChange={(e: ChangeEvent<HTMLInputElement>): void => setHopsValue(e.target.value)}
/>
</InputBox>
</span>
Expand Down

0 comments on commit 807d3dc

Please sign in to comment.