bug fixes

This commit is contained in:
ingawei 2022-09-20 23:01:38 -07:00
parent aed48dfb22
commit ff6ce54b4b
3 changed files with 18 additions and 18 deletions

View File

@ -2,7 +2,11 @@ import { useState } from 'react'
import clsx from 'clsx' import clsx from 'clsx'
import { BuyPanel, SimpleBetPanel } from './bet-panel' import { BuyPanel, SimpleBetPanel } from './bet-panel'
import { CPMMBinaryContract, PseudoNumericContract } from 'common/contract' import {
BinaryContract,
CPMMBinaryContract,
PseudoNumericContract,
} from 'common/contract'
import { Modal } from './layout/modal' import { Modal } from './layout/modal'
import { useUser } from 'web/hooks/use-user' import { useUser } from 'web/hooks/use-user'
import { useUserContractBets } from 'web/hooks/use-user-bets' import { useUserContractBets } from 'web/hooks/use-user-bets'
@ -78,9 +82,7 @@ export default function BetButton(props: {
) )
} }
export function BinaryMobileBetting(props: { export function BinaryMobileBetting(props: { contract: CPMMBinaryContract }) {
contract: CPMMBinaryContract | Contract
}) {
const { contract } = props const { contract } = props
const user = useUser() const user = useUser()
if (user) { if (user) {
@ -99,13 +101,10 @@ export function BinaryMobileBetting(props: {
} }
export function SignedInBinaryMobileBetting(props: { export function SignedInBinaryMobileBetting(props: {
contract: CPMMBinaryContract | Contract contract: CPMMBinaryContract | PseudoNumericContract
user: User user: User
}) { }) {
const { contract, user } = props const { contract, user } = props
const [betChoice, _setBetChoice] = useState<'YES' | 'NO' | undefined>(
undefined
)
const unfilledBets = useUnfilledBets(contract.id) ?? [] const unfilledBets = useUnfilledBets(contract.id) ?? []
return ( return (
@ -117,7 +116,6 @@ export function SignedInBinaryMobileBetting(props: {
contract={contract} contract={contract}
user={user} user={user}
unfilledBets={unfilledBets} unfilledBets={unfilledBets}
selected={betChoice}
mobileView={true} mobileView={true}
/> />
</Col> </Col>

View File

@ -3,7 +3,11 @@ import React, { useState } from 'react'
import { clamp, partition, sumBy } from 'lodash' import { clamp, partition, sumBy } from 'lodash'
import { useUser } from 'web/hooks/use-user' import { useUser } from 'web/hooks/use-user'
import { CPMMBinaryContract, PseudoNumericContract } from 'common/contract' import {
Contract,
CPMMBinaryContract,
PseudoNumericContract,
} from 'common/contract'
import { Col } from './layout/col' import { Col } from './layout/col'
import { Row } from './layout/row' import { Row } from './layout/row'
import { Spacer } from './layout/spacer' import { Spacer } from './layout/spacer'
@ -146,7 +150,6 @@ export function SimpleBetPanel(props: {
contract={contract} contract={contract}
user={user} user={user}
unfilledBets={unfilledBets} unfilledBets={unfilledBets}
selected={selected}
onBuySuccess={onBetSuccess} onBuySuccess={onBetSuccess}
/> />
<LimitOrderPanel <LimitOrderPanel
@ -481,7 +484,6 @@ function LimitOrderPanel(props: {
const betChoice = 'YES' const betChoice = 'YES'
const [error, setError] = useState<string | undefined>() const [error, setError] = useState<string | undefined>()
const [isSubmitting, setIsSubmitting] = useState(false) const [isSubmitting, setIsSubmitting] = useState(false)
const [wasSubmitted, setWasSubmitted] = useState(false)
const rangeError = const rangeError =
lowLimitProb !== undefined && lowLimitProb !== undefined &&
@ -529,7 +531,6 @@ function LimitOrderPanel(props: {
const noAmount = shares * (1 - (noLimitProb ?? 0)) const noAmount = shares * (1 - (noLimitProb ?? 0))
function onBetChange(newAmount: number | undefined) { function onBetChange(newAmount: number | undefined) {
setWasSubmitted(false)
setBetAmount(newAmount) setBetAmount(newAmount)
} }
@ -574,7 +575,6 @@ function LimitOrderPanel(props: {
.then((r) => { .then((r) => {
console.log('placed bet. Result:', r) console.log('placed bet. Result:', r)
setIsSubmitting(false) setIsSubmitting(false)
setWasSubmitted(true)
setBetAmount(undefined) setBetAmount(undefined)
setLowLimitProb(undefined) setLowLimitProb(undefined)
setHighLimitProb(undefined) setHighLimitProb(undefined)
@ -810,8 +810,6 @@ function LimitOrderPanel(props: {
: `Submit order${hasTwoBets ? 's' : ''}`} : `Submit order${hasTwoBets ? 's' : ''}`}
</button> </button>
)} )}
{wasSubmitted && <div className="mt-4">Order submitted!</div>}
</Col> </Col>
) )
} }

View File

@ -23,6 +23,7 @@ import {
MultipleChoiceContract, MultipleChoiceContract,
NumericContract, NumericContract,
PseudoNumericContract, PseudoNumericContract,
CPMMBinaryContract,
} from 'common/contract' } from 'common/contract'
import { ContractDetails } from './contract-details' import { ContractDetails } from './contract-details'
import { NumericGraph } from './numeric-graph' import { NumericGraph } from './numeric-graph'
@ -68,7 +69,10 @@ const NumericOverview = (props: { contract: NumericContract }) => {
) )
} }
const BinaryOverview = (props: { contract: BinaryContract; bets: Bet[] }) => { const BinaryOverview = (props: {
contract: CPMMBinaryContract
bets: Bet[]
}) => {
const { contract, bets } = props const { contract, bets } = props
return ( return (
<Col className="gap-1 md:gap-2"> <Col className="gap-1 md:gap-2">
@ -86,7 +90,7 @@ const BinaryOverview = (props: { contract: BinaryContract; bets: Bet[] }) => {
<ContractProbGraph contract={contract} bets={[...bets].reverse()} /> <ContractProbGraph contract={contract} bets={[...bets].reverse()} />
<Row className="items-center justify-between gap-4 xl:hidden"> <Row className="items-center justify-between gap-4 xl:hidden">
{tradingAllowed(contract) && ( {tradingAllowed(contract) && (
<BinaryMobileBetting className={'my-2'} contract={contract} /> <BinaryMobileBetting contract={contract} />
)} )}
</Row> </Row>
</Col> </Col>