48a249eaa9
* Add Firestore package and config * Upload basic Firebase Auth code * Basic ability to sign in and view profile * Move html head content to Next's _document * Apply dark theme to all DaisyUI components * Add contract page * Smaller width bet input * Add some buttons * Add Row, Col, and Spacer components * Implement skeleton ContractPage * Apply dark theme to all DaisyUI components * Fix hooks lints (#3) * Add background to bet panel * Changes based on review comments Co-authored-by: Austin Chen <akrolsmir@gmail.com>
53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
import React, { useState } from 'react'
|
|
import { Contract } from '../lib/firebase/contracts'
|
|
import { Col } from './layout/col'
|
|
import { Spacer } from './layout/spacer'
|
|
import { YesNoSelector } from './yes-no-selector'
|
|
|
|
export function BetPanel(props: { contract: Contract; className?: string }) {
|
|
const { contract, className } = props
|
|
|
|
const [betChoice, setBetChoice] = useState<'YES' | 'NO'>('YES')
|
|
const [shares, setShares] = useState(0)
|
|
|
|
return (
|
|
<Col className={'bg-gray-600 p-6 rounded ' + className}>
|
|
<div className="p-2 font-medium">Pick outcome</div>
|
|
<YesNoSelector
|
|
className="p-2"
|
|
selected={betChoice}
|
|
onSelect={setBetChoice}
|
|
yesLabel="Yes 57"
|
|
noLabel="No 43"
|
|
/>
|
|
|
|
<Spacer h={4} />
|
|
|
|
<div className="p-2 font-medium">Shares</div>
|
|
<div className="p-2">
|
|
<input
|
|
className="input input-bordered input-md"
|
|
style={{ maxWidth: 80 }}
|
|
type="text"
|
|
value={shares}
|
|
onChange={(e) => setShares(parseInt(e.target.value) || 0)}
|
|
onFocus={(e) => e.target.select()}
|
|
/>
|
|
</div>
|
|
|
|
<Spacer h={4} />
|
|
|
|
<div className="p-2 font-medium">Price</div>
|
|
<div className="px-2">
|
|
{shares * (betChoice === 'YES' ? 57 : 43)} points
|
|
</div>
|
|
|
|
<Spacer h={6} />
|
|
|
|
{shares !== 0 && (
|
|
<button className="btn btn-primary">Place bet</button>
|
|
)}
|
|
</Col>
|
|
)
|
|
}
|