2022-07-02 19:37:59 +00:00
|
|
|
import { CPMMBinaryContract, PseudoNumericContract } from 'common/contract'
|
2022-05-09 13:04:36 +00:00
|
|
|
import { Bet } from 'common/bet'
|
|
|
|
import { User } from 'common/user'
|
2022-04-20 14:13:39 +00:00
|
|
|
import { Modal } from './layout/modal'
|
|
|
|
import { Col } from './layout/col'
|
|
|
|
import { Title } from './title'
|
2022-05-09 13:04:36 +00:00
|
|
|
import { formatWithCommas } from 'common/util/format'
|
2022-04-20 14:13:39 +00:00
|
|
|
import { OutcomeLabel } from './outcome-label'
|
|
|
|
import { SellPanel } from './bet-panel'
|
2022-05-17 17:31:19 +00:00
|
|
|
import clsx from 'clsx'
|
2022-04-20 14:13:39 +00:00
|
|
|
|
|
|
|
export function SellSharesModal(props: {
|
2022-05-17 17:31:19 +00:00
|
|
|
className?: string
|
2022-07-02 19:37:59 +00:00
|
|
|
contract: CPMMBinaryContract | PseudoNumericContract
|
2022-04-20 14:13:39 +00:00
|
|
|
userBets: Bet[]
|
|
|
|
shares: number
|
|
|
|
sharesOutcome: 'YES' | 'NO'
|
|
|
|
user: User
|
|
|
|
setOpen: (open: boolean) => void
|
|
|
|
}) {
|
2022-05-17 17:31:19 +00:00
|
|
|
const {
|
|
|
|
className,
|
|
|
|
contract,
|
|
|
|
shares,
|
|
|
|
sharesOutcome,
|
|
|
|
userBets,
|
|
|
|
user,
|
|
|
|
setOpen,
|
|
|
|
} = props
|
2022-04-20 14:13:39 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Modal open={true} setOpen={setOpen}>
|
2022-05-17 17:31:19 +00:00
|
|
|
<Col className={clsx('rounded-md bg-white px-8 py-6', className)}>
|
2022-04-20 14:13:39 +00:00
|
|
|
<Title className="!mt-0" text={'Sell shares'} />
|
|
|
|
|
|
|
|
<div className="mb-6">
|
|
|
|
You have {formatWithCommas(Math.floor(shares))}{' '}
|
|
|
|
<OutcomeLabel
|
|
|
|
outcome={sharesOutcome}
|
|
|
|
contract={contract}
|
|
|
|
truncate={'short'}
|
|
|
|
/>{' '}
|
|
|
|
shares
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<SellPanel
|
|
|
|
contract={contract}
|
|
|
|
shares={shares}
|
|
|
|
sharesOutcome={sharesOutcome}
|
|
|
|
user={user}
|
|
|
|
userBets={userBets ?? []}
|
|
|
|
onSellSuccess={() => setOpen(false)}
|
|
|
|
/>
|
|
|
|
</Col>
|
|
|
|
</Modal>
|
|
|
|
)
|
|
|
|
}
|