3b953a7c21
* Prototype range limit order UI * Conditionally show YES or NO max payout * Range bet executes both bets immediately. * Validate lowLimitProb < highLimitProb * Show error if low limit is higher than high limit * Update range order UI * Revert "Validate lowLimitProb < highLimitProb" This reverts commitc261fc2743
. * Revert "Range bet executes both bets immediately." This reverts commit30b95d75d9
. * Buy panel only non-limit orders * Bet choice => outcome * More iterating on range UI * betChoice => outcome * Lighten placeholder text
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import { useState } from 'react'
|
|
|
|
import { NumericContract, PseudoNumericContract } from 'common/contract'
|
|
import { getMappedBucket } from 'common/calculate-dpm'
|
|
|
|
import { NumberInput } from './number-input'
|
|
|
|
export function BucketInput(props: {
|
|
contract: NumericContract | PseudoNumericContract
|
|
isSubmitting?: boolean
|
|
onBucketChange: (value?: number, bucket?: string) => void
|
|
placeholder?: string
|
|
}) {
|
|
const { contract, isSubmitting, onBucketChange, placeholder } = props
|
|
|
|
const [numberString, setNumberString] = useState('')
|
|
|
|
const onChange = (s: string) => {
|
|
setNumberString(s)
|
|
|
|
const value = parseFloat(s)
|
|
|
|
if (!isFinite(value)) {
|
|
onBucketChange(undefined, undefined)
|
|
return
|
|
}
|
|
|
|
const bucket =
|
|
contract.outcomeType === 'PSEUDO_NUMERIC'
|
|
? ''
|
|
: getMappedBucket(value, contract)
|
|
|
|
onBucketChange(value, bucket)
|
|
}
|
|
|
|
return (
|
|
<NumberInput
|
|
inputClassName="w-full max-w-none"
|
|
onChange={onChange}
|
|
error={undefined}
|
|
disabled={isSubmitting}
|
|
numberString={numberString}
|
|
placeholder={placeholder}
|
|
/>
|
|
)
|
|
}
|