Prompt for sign in from bet panel

This commit is contained in:
Austin Chen 2021-12-17 23:09:11 -08:00
parent db122fb614
commit f6c45a29c2

View File

@ -15,6 +15,7 @@ import {
getDpmWeight, getDpmWeight,
getProbabilityAfterBet, getProbabilityAfterBet,
} from '../lib/calculation/contract' } from '../lib/calculation/contract'
import { firebaseLogin } from '../lib/firebase/users'
export function BetPanel(props: { contract: Contract; className?: string }) { export function BetPanel(props: { contract: Contract; className?: string }) {
const { contract, className } = props const { contract, className } = props
@ -132,8 +133,14 @@ export function BetPanel(props: { contract: Contract; className?: string }) {
)} )}
</Col> </Col>
<div className="mt-3 mb-1 text-sm text-gray-400">Remaining balance</div> {user && (
<div>{formatMoney(remainingBalance > 0 ? remainingBalance : 0)}</div> <>
<div className="mt-3 mb-1 text-sm text-gray-400">
Remaining balance
</div>
<div>{formatMoney(remainingBalance > 0 ? remainingBalance : 0)}</div>
</>
)}
<div className="mt-2 mb-1 text-sm text-gray-400">Implied probability</div> <div className="mt-2 mb-1 text-sm text-gray-400">Implied probability</div>
<Row> <Row>
@ -151,20 +158,29 @@ export function BetPanel(props: { contract: Contract; className?: string }) {
<Spacer h={6} /> <Spacer h={6} />
<button {user ? (
className={clsx( <button
'btn', className={clsx(
betDisabled 'btn',
? 'btn-disabled' betDisabled
: betChoice === 'YES' ? 'btn-disabled'
? 'btn-primary' : betChoice === 'YES'
: 'bg-red-400 hover:bg-red-500 border-none', ? 'btn-primary'
isSubmitting ? 'loading' : '' : 'bg-red-400 hover:bg-red-500 border-none',
)} isSubmitting ? 'loading' : ''
onClick={betDisabled ? undefined : submitBet} )}
> onClick={betDisabled ? undefined : submitBet}
{isSubmitting ? 'Submitting...' : 'Place bet'} >
</button> {isSubmitting ? 'Submitting...' : 'Place bet'}
</button>
) : (
<button
className="btn mt-4 border-none normal-case text-lg font-medium px-10 bg-gradient-to-r from-teal-500 to-green-500 hover:from-teal-600 hover:to-green-600"
onClick={firebaseLogin}
>
Sign in to bet!
</button>
)}
{wasSubmitted && <div className="mt-4">Bet submitted!</div>} {wasSubmitted && <div className="mt-4">Bet submitted!</div>}
</Col> </Col>