2021-12-14 00:00:02 +00:00
|
|
|
import clsx from 'clsx'
|
2021-12-10 14:56:17 +00:00
|
|
|
import React from 'react'
|
2022-01-30 21:51:30 +00:00
|
|
|
import { formatMoney } from '../../common/util/format'
|
2022-01-02 06:27:58 +00:00
|
|
|
import { Col } from './layout/col'
|
2021-12-10 14:56:17 +00:00
|
|
|
import { Row } from './layout/row'
|
|
|
|
|
|
|
|
export function YesNoSelector(props: {
|
2022-01-26 20:08:03 +00:00
|
|
|
selected?: 'YES' | 'NO'
|
2021-12-10 14:56:17 +00:00
|
|
|
onSelect: (selected: 'YES' | 'NO') => void
|
|
|
|
className?: string
|
2022-01-27 20:49:55 +00:00
|
|
|
btnClassName?: string
|
2021-12-10 14:56:17 +00:00
|
|
|
}) {
|
2022-01-27 20:49:55 +00:00
|
|
|
const { selected, onSelect, className, btnClassName } = props
|
2021-12-10 14:56:17 +00:00
|
|
|
|
2022-03-29 19:56:56 +00:00
|
|
|
const commonClassNames =
|
|
|
|
'inline-flex flex-1 items-center justify-center rounded-3xl border-2 p-2'
|
|
|
|
|
2021-12-10 14:56:17 +00:00
|
|
|
return (
|
2021-12-14 00:00:02 +00:00
|
|
|
<Row className={clsx('space-x-3', className)}>
|
2022-01-26 20:08:03 +00:00
|
|
|
<button
|
|
|
|
className={clsx(
|
2022-03-29 19:56:56 +00:00
|
|
|
commonClassNames,
|
|
|
|
'hover:bg-primary-focus border-primary hover:border-primary-focus hover:text-white',
|
2022-01-26 20:08:03 +00:00
|
|
|
selected == 'YES'
|
|
|
|
? 'bg-primary text-white'
|
2022-02-11 18:40:22 +00:00
|
|
|
: 'text-primary bg-transparent',
|
2022-01-27 20:49:55 +00:00
|
|
|
btnClassName
|
2022-01-26 20:08:03 +00:00
|
|
|
)}
|
2021-12-10 14:56:17 +00:00
|
|
|
onClick={() => onSelect('YES')}
|
|
|
|
>
|
2022-04-09 21:13:36 +00:00
|
|
|
Bet YES
|
2022-01-26 20:08:03 +00:00
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
className={clsx(
|
2022-03-29 19:56:56 +00:00
|
|
|
commonClassNames,
|
|
|
|
'border-red-400 hover:border-red-500 hover:bg-red-500 hover:text-white',
|
2022-01-26 20:08:03 +00:00
|
|
|
selected == 'NO'
|
|
|
|
? 'bg-red-400 text-white'
|
2022-01-27 20:49:55 +00:00
|
|
|
: 'bg-transparent text-red-400',
|
|
|
|
btnClassName
|
2022-01-26 20:08:03 +00:00
|
|
|
)}
|
2021-12-10 14:56:17 +00:00
|
|
|
onClick={() => onSelect('NO')}
|
|
|
|
>
|
2022-04-09 21:13:36 +00:00
|
|
|
Bet NO
|
2022-01-26 20:08:03 +00:00
|
|
|
</button>
|
2021-12-14 00:00:02 +00:00
|
|
|
</Row>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export function YesNoCancelSelector(props: {
|
2022-01-02 06:27:58 +00:00
|
|
|
selected: 'YES' | 'NO' | 'MKT' | 'CANCEL' | undefined
|
|
|
|
onSelect: (selected: 'YES' | 'NO' | 'MKT' | 'CANCEL') => void
|
2021-12-14 00:00:02 +00:00
|
|
|
className?: string
|
2021-12-15 18:44:34 +00:00
|
|
|
btnClassName?: string
|
2021-12-14 00:00:02 +00:00
|
|
|
}) {
|
2022-02-13 23:41:08 +00:00
|
|
|
const { selected, onSelect } = props
|
2021-12-14 00:00:02 +00:00
|
|
|
|
2022-03-29 19:56:56 +00:00
|
|
|
const btnClassName = clsx('px-6 flex-1 rounded-3xl', props.btnClassName)
|
2021-12-15 18:44:34 +00:00
|
|
|
|
2021-12-14 00:00:02 +00:00
|
|
|
return (
|
2022-02-13 23:41:08 +00:00
|
|
|
<Col className="gap-2">
|
|
|
|
{/* Should ideally use a radio group instead of buttons */}
|
|
|
|
<Button
|
|
|
|
color={selected === 'YES' ? 'green' : 'gray'}
|
|
|
|
onClick={() => onSelect('YES')}
|
|
|
|
className={btnClassName}
|
|
|
|
>
|
|
|
|
YES
|
|
|
|
</Button>
|
2021-12-14 00:00:02 +00:00
|
|
|
|
2022-02-13 23:41:08 +00:00
|
|
|
<Button
|
|
|
|
color={selected === 'NO' ? 'red' : 'gray'}
|
|
|
|
onClick={() => onSelect('NO')}
|
|
|
|
className={btnClassName}
|
|
|
|
>
|
|
|
|
NO
|
|
|
|
</Button>
|
2021-12-14 00:00:02 +00:00
|
|
|
|
2022-02-13 23:41:08 +00:00
|
|
|
<Button
|
|
|
|
color={selected === 'MKT' ? 'blue' : 'gray'}
|
|
|
|
onClick={() => onSelect('MKT')}
|
|
|
|
className={clsx(btnClassName, 'btn-sm')}
|
|
|
|
>
|
|
|
|
PROB
|
|
|
|
</Button>
|
2022-01-02 06:27:58 +00:00
|
|
|
|
2022-02-13 23:41:08 +00:00
|
|
|
<Button
|
|
|
|
color={selected === 'CANCEL' ? 'yellow' : 'gray'}
|
|
|
|
onClick={() => onSelect('CANCEL')}
|
|
|
|
className={clsx(btnClassName, 'btn-sm')}
|
|
|
|
>
|
|
|
|
N/A
|
|
|
|
</Button>
|
2022-01-02 06:27:58 +00:00
|
|
|
</Col>
|
2021-12-10 14:56:17 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-02-17 23:00:19 +00:00
|
|
|
export function ChooseCancelSelector(props: {
|
2022-02-20 07:26:26 +00:00
|
|
|
selected: 'CHOOSE' | 'CHOOSE_MULTIPLE' | 'CANCEL' | undefined
|
|
|
|
onSelect: (selected: 'CHOOSE' | 'CHOOSE_MULTIPLE' | 'CANCEL') => void
|
2022-02-17 23:00:19 +00:00
|
|
|
className?: string
|
|
|
|
btnClassName?: string
|
|
|
|
}) {
|
|
|
|
const { selected, onSelect, className } = props
|
|
|
|
|
|
|
|
const btnClassName = clsx('px-6 flex-1', props.btnClassName)
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Col className={clsx('gap-2', className)}>
|
|
|
|
<Button
|
|
|
|
color={selected === 'CHOOSE' ? 'green' : 'gray'}
|
|
|
|
onClick={() => onSelect('CHOOSE')}
|
|
|
|
className={clsx('whitespace-nowrap', btnClassName)}
|
|
|
|
>
|
|
|
|
Choose an answer
|
|
|
|
</Button>
|
|
|
|
|
2022-02-20 07:26:26 +00:00
|
|
|
<Button
|
|
|
|
color={selected === 'CHOOSE_MULTIPLE' ? 'blue' : 'gray'}
|
|
|
|
onClick={() => onSelect('CHOOSE_MULTIPLE')}
|
|
|
|
className={clsx('whitespace-nowrap', btnClassName)}
|
|
|
|
>
|
|
|
|
Choose multiple
|
|
|
|
</Button>
|
|
|
|
|
2022-02-17 23:00:19 +00:00
|
|
|
<Button
|
|
|
|
color={selected === 'CANCEL' ? 'yellow' : 'gray'}
|
|
|
|
onClick={() => onSelect('CANCEL')}
|
|
|
|
className={clsx(btnClassName, '')}
|
|
|
|
>
|
|
|
|
N/A
|
|
|
|
</Button>
|
|
|
|
</Col>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-04-09 23:56:05 +00:00
|
|
|
const fundAmounts = [1000, 2500, 10000]
|
2022-01-07 22:56:14 +00:00
|
|
|
|
|
|
|
export function FundsSelector(props: {
|
2022-04-09 23:56:05 +00:00
|
|
|
selected: 1000 | 2500 | 10000
|
|
|
|
onSelect: (selected: 1000 | 2500 | 10000) => void
|
2022-01-07 22:56:14 +00:00
|
|
|
className?: string
|
|
|
|
btnClassName?: string
|
|
|
|
}) {
|
|
|
|
const { selected, onSelect, className } = props
|
2022-01-14 03:15:44 +00:00
|
|
|
const btnClassName = clsx('!px-2 whitespace-nowrap', props.btnClassName)
|
2022-01-07 22:56:14 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Row className={clsx('space-x-3', className)}>
|
|
|
|
{fundAmounts.map((amount) => (
|
|
|
|
<Button
|
|
|
|
key={amount}
|
|
|
|
color={selected === amount ? 'green' : 'gray'}
|
|
|
|
onClick={() => onSelect(amount as any)}
|
|
|
|
className={btnClassName}
|
|
|
|
>
|
|
|
|
{formatMoney(amount)}
|
|
|
|
</Button>
|
|
|
|
))}
|
|
|
|
</Row>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-02-17 23:00:19 +00:00
|
|
|
export function BuyButton(props: { className?: string; onClick?: () => void }) {
|
|
|
|
const { className, onClick } = props
|
2022-03-17 04:42:24 +00:00
|
|
|
// Note: styles coppied from YesNoSelector
|
2022-02-17 23:00:19 +00:00
|
|
|
return (
|
2022-03-17 04:42:24 +00:00
|
|
|
<button
|
|
|
|
className={clsx(
|
|
|
|
'hover:bg-primary-focus border-primary hover:border-primary-focus inline-flex flex-1 items-center justify-center rounded-lg border-2 p-2 hover:text-white',
|
|
|
|
'text-primary bg-transparent text-lg',
|
|
|
|
className
|
|
|
|
)}
|
|
|
|
onClick={onClick}
|
|
|
|
>
|
2022-04-09 21:13:36 +00:00
|
|
|
Bet
|
2022-03-17 04:42:24 +00:00
|
|
|
</button>
|
2022-02-17 23:00:19 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-12-10 14:56:17 +00:00
|
|
|
function Button(props: {
|
|
|
|
className?: string
|
|
|
|
onClick?: () => void
|
2022-01-02 06:27:58 +00:00
|
|
|
color: 'green' | 'red' | 'blue' | 'yellow' | 'gray'
|
2021-12-10 14:56:17 +00:00
|
|
|
children?: any
|
|
|
|
}) {
|
2021-12-14 00:00:02 +00:00
|
|
|
const { className, onClick, children, color } = props
|
2021-12-10 14:56:17 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<button
|
|
|
|
type="button"
|
2021-12-14 00:00:02 +00:00
|
|
|
className={clsx(
|
2022-02-17 23:00:19 +00:00
|
|
|
'inline-flex flex-1 items-center justify-center rounded-md border border-transparent px-8 py-3 font-medium shadow-sm',
|
2022-02-08 05:52:03 +00:00
|
|
|
color === 'green' && 'btn-primary text-white',
|
2022-02-11 18:40:22 +00:00
|
|
|
color === 'red' && 'bg-red-400 text-white hover:bg-red-500',
|
|
|
|
color === 'yellow' && 'bg-yellow-400 text-white hover:bg-yellow-500',
|
|
|
|
color === 'blue' && 'bg-blue-400 text-white hover:bg-blue-500',
|
2022-04-18 23:02:40 +00:00
|
|
|
color === 'gray' && 'bg-gray-200 text-gray-700 hover:bg-gray-300',
|
2021-12-10 14:56:17 +00:00
|
|
|
className
|
|
|
|
)}
|
|
|
|
onClick={onClick}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</button>
|
|
|
|
)
|
|
|
|
}
|