diff --git a/web/components/bet-panel.tsx b/web/components/bet-panel.tsx
index 14acaaa0..adaa9b19 100644
--- a/web/components/bet-panel.tsx
+++ b/web/components/bet-panel.tsx
@@ -1,6 +1,7 @@
import clsx from 'clsx'
import React, { useEffect, useState } from 'react'
import { partition, sumBy } from 'lodash'
+import { SwitchHorizontalIcon } from '@heroicons/react/solid'
import { useUser } from 'web/hooks/use-user'
import { BinaryContract, CPMMBinaryContract } from 'common/contract'
@@ -38,6 +39,7 @@ import { SellRow } from './sell-row'
import { useSaveShares } from './use-save-shares'
import { SignUpPrompt } from './sign-up-prompt'
import { isIOS } from 'web/lib/util/device'
+import { ProbabilityInput } from './probability-input'
export function BetPanel(props: {
contract: BinaryContract
@@ -53,6 +55,8 @@ export function BetPanel(props: {
? 'NO'
: undefined
+ const [isLimitOrder, setIsLimitOrder] = useState(false)
+
return (
- Place your bet
- {/* */}
+
+
+ {isLimitOrder ? <>Bet to a probability> : <>Place your bet>}
+
-
+
@@ -190,13 +202,19 @@ export function BetPanelSwitcher(props: {
function BuyPanel(props: {
contract: BinaryContract
user: User | null | undefined
+ isLimitOrder?: boolean
selected?: 'YES' | 'NO'
onBuySuccess?: () => void
}) {
- const { contract, user, selected, onBuySuccess } = props
+ const { contract, user, isLimitOrder, selected, onBuySuccess } = props
+
+ const initialProb = getProbability(contract)
const [betChoice, setBetChoice] = useState<'YES' | 'NO' | undefined>(selected)
const [betAmount, setBetAmount] = useState(undefined)
+ const [betProb, setBetProb] = useState(
+ Math.round(100 * initialProb)
+ )
const [error, setError] = useState()
const [isSubmitting, setIsSubmitting] = useState(false)
const [wasSubmitted, setWasSubmitted] = useState(false)
@@ -255,8 +273,6 @@ function BuyPanel(props: {
const betDisabled = isSubmitting || !betAmount || error
- const initialProb = getProbability(contract)
-
const outcomeProb = getOutcomeProbabilityAfterBet(
contract,
betChoice || 'YES',
@@ -309,16 +325,32 @@ function BuyPanel(props: {
disabled={isSubmitting}
inputRef={inputRef}
/>
-
-
-
- Probability
-
- {formatPercent(initialProb)}
-
→
- {formatPercent(resultProb)}
+ {isLimitOrder && (
+ <>
+
+ Probability
-
+
+ >
+ )}
+
+ {!isLimitOrder && (
+
+ Probability
+
+ {formatPercent(initialProb)}
+ →
+ {formatPercent(resultProb)}
+
+
+ )}
diff --git a/web/components/probability-input.tsx b/web/components/probability-input.tsx
new file mode 100644
index 00000000..c80ea013
--- /dev/null
+++ b/web/components/probability-input.tsx
@@ -0,0 +1,55 @@
+import clsx from 'clsx'
+import { Col } from './layout/col'
+import { Spacer } from './layout/spacer'
+
+export function ProbabilityInput(props: {
+ prob: number | undefined
+ onChange: (newProb: number | undefined) => void
+ error: string | undefined
+ setError: (error: string | undefined) => void
+ disabled?: boolean
+ className?: string
+ inputClassName?: string
+}) {
+ const { prob, onChange, error, disabled, className, inputClassName } = props
+
+ const onProbChange = (str: string) => {
+ let prob = parseInt(str.replace(/\D/g, ''))
+ const isInvalid = !str || isNaN(prob)
+ if (prob.toString().length > 2) prob = +prob.toString().slice(0, 2)
+ onChange(isInvalid ? undefined : prob)
+ }
+
+ return (
+
+
+
+
+
+ {error && (
+
+ {error}
+
+ )}
+
+ )
+}