2022-01-27 21:02:47 +00:00
|
|
|
import clsx from 'clsx'
|
2022-03-29 19:56:56 +00:00
|
|
|
import { useState } from 'react'
|
2022-03-15 22:27:51 +00:00
|
|
|
|
2022-03-29 19:56:56 +00:00
|
|
|
import { BetPanelSwitcher } from './bet-panel'
|
2022-01-26 20:08:03 +00:00
|
|
|
import { Row } from './layout/row'
|
|
|
|
import { YesNoSelector } from './yes-no-selector'
|
2022-03-15 22:27:51 +00:00
|
|
|
import { Binary, CPMM, DPM, FullContract } from '../../common/contract'
|
2022-03-29 19:56:56 +00:00
|
|
|
import { Modal } from './layout/modal'
|
2022-01-26 20:08:03 +00:00
|
|
|
|
|
|
|
// Inline version of a bet panel. Opens BetPanel in a new modal.
|
2022-01-26 22:28:57 +00:00
|
|
|
export default function BetRow(props: {
|
2022-03-15 22:27:51 +00:00
|
|
|
contract: FullContract<DPM | CPMM, Binary>
|
2022-01-26 22:28:57 +00:00
|
|
|
className?: string
|
2022-01-27 21:02:47 +00:00
|
|
|
labelClassName?: string
|
2022-01-26 22:28:57 +00:00
|
|
|
}) {
|
2022-01-27 21:02:47 +00:00
|
|
|
const { className, labelClassName } = props
|
2022-01-26 20:08:03 +00:00
|
|
|
const [open, setOpen] = useState(false)
|
|
|
|
const [betChoice, setBetChoice] = useState<'YES' | 'NO' | undefined>(
|
|
|
|
undefined
|
|
|
|
)
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2022-01-27 21:02:47 +00:00
|
|
|
<div className={className}>
|
2022-02-11 18:40:22 +00:00
|
|
|
<Row className="items-center justify-end gap-2">
|
2022-04-09 21:13:36 +00:00
|
|
|
{/* <div className={clsx('mr-2 text-gray-400', labelClassName)}>
|
2022-01-27 21:02:47 +00:00
|
|
|
Place a trade
|
2022-04-09 21:13:36 +00:00
|
|
|
</div> */}
|
2022-01-27 21:02:47 +00:00
|
|
|
<YesNoSelector
|
2022-03-29 19:56:56 +00:00
|
|
|
btnClassName="btn-sm w-24"
|
2022-01-27 21:02:47 +00:00
|
|
|
onSelect={(choice) => {
|
|
|
|
setOpen(true)
|
|
|
|
setBetChoice(choice)
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Row>
|
|
|
|
<Modal open={open} setOpen={setOpen}>
|
2022-03-29 19:56:56 +00:00
|
|
|
<BetPanelSwitcher
|
2022-01-27 21:02:47 +00:00
|
|
|
contract={props.contract}
|
|
|
|
title={props.contract.question}
|
|
|
|
selected={betChoice}
|
2022-02-05 18:26:11 +00:00
|
|
|
onBetSuccess={() => setOpen(false)}
|
2022-01-27 21:02:47 +00:00
|
|
|
/>
|
|
|
|
</Modal>
|
|
|
|
</div>
|
2022-01-26 20:08:03 +00:00
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|