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-07 22:56:14 +00:00
|
|
|
import { formatMoney } from '../lib/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
|
|
|
|
|
|
|
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(
|
|
|
|
'flex-1 inline-flex justify-center items-center p-2 hover:bg-primary-focus hover:text-white rounded-lg border-primary hover:border-primary-focus border-2',
|
|
|
|
selected == 'YES'
|
|
|
|
? 'bg-primary text-white'
|
2022-01-27 20:49:55 +00:00
|
|
|
: 'bg-transparent text-primary',
|
|
|
|
btnClassName
|
2022-01-26 20:08:03 +00:00
|
|
|
)}
|
2021-12-10 14:56:17 +00:00
|
|
|
onClick={() => onSelect('YES')}
|
|
|
|
>
|
2022-01-26 22:28:57 +00:00
|
|
|
Buy YES
|
2022-01-26 20:08:03 +00:00
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
className={clsx(
|
|
|
|
'flex-1 inline-flex justify-center items-center p-2 hover:bg-red-500 hover:text-white rounded-lg border-red-400 hover:border-red-500 border-2',
|
|
|
|
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-01-26 22:28:57 +00:00
|
|
|
Buy 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
|
|
|
}) {
|
|
|
|
const { selected, onSelect, className } = props
|
|
|
|
|
2022-01-02 06:27:58 +00:00
|
|
|
const btnClassName = clsx('px-6 flex-1', props.btnClassName)
|
2021-12-15 18:44:34 +00:00
|
|
|
|
2021-12-14 00:00:02 +00:00
|
|
|
return (
|
2022-01-02 06:27:58 +00:00
|
|
|
<Col>
|
|
|
|
<Row className={clsx('space-x-3 w-full', className)}>
|
|
|
|
<Button
|
|
|
|
color={selected === 'YES' ? 'green' : 'gray'}
|
|
|
|
onClick={() => onSelect('YES')}
|
|
|
|
className={btnClassName}
|
|
|
|
>
|
|
|
|
YES
|
|
|
|
</Button>
|
2021-12-14 00:00:02 +00:00
|
|
|
|
2022-01-02 06:27:58 +00:00
|
|
|
<Button
|
|
|
|
color={selected === 'NO' ? 'red' : 'gray'}
|
|
|
|
onClick={() => onSelect('NO')}
|
|
|
|
className={btnClassName}
|
|
|
|
>
|
|
|
|
NO
|
|
|
|
</Button>
|
|
|
|
</Row>
|
2021-12-14 00:00:02 +00:00
|
|
|
|
2022-01-02 06:27:58 +00:00
|
|
|
<Row className={clsx('space-x-3 w-full', className)}>
|
|
|
|
<Button
|
|
|
|
color={selected === 'MKT' ? 'blue' : 'gray'}
|
|
|
|
onClick={() => onSelect('MKT')}
|
|
|
|
className={clsx(btnClassName, 'btn-sm')}
|
|
|
|
>
|
|
|
|
MKT
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
<Button
|
|
|
|
color={selected === 'CANCEL' ? 'yellow' : 'gray'}
|
|
|
|
onClick={() => onSelect('CANCEL')}
|
|
|
|
className={clsx(btnClassName, 'btn-sm')}
|
|
|
|
>
|
|
|
|
N/A
|
|
|
|
</Button>
|
|
|
|
</Row>
|
|
|
|
</Col>
|
2021-12-10 14:56:17 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-01-07 22:56:14 +00:00
|
|
|
const fundAmounts = [500, 1000, 2500, 10000]
|
|
|
|
|
|
|
|
export function FundsSelector(props: {
|
|
|
|
selected: 500 | 1000 | 2500 | 10000
|
|
|
|
onSelect: (selected: 500 | 1000 | 2500 | 10000) => void
|
|
|
|
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>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
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(
|
2021-12-16 04:55:03 +00:00
|
|
|
'flex-1 inline-flex justify-center items-center px-8 py-3 border border-transparent rounded-md shadow-sm text-sm font-medium text-white',
|
2021-12-13 18:26:46 +00:00
|
|
|
color === 'green' && 'btn-primary',
|
2021-12-14 00:00:02 +00:00
|
|
|
color === 'red' && 'bg-red-400 hover:bg-red-500',
|
|
|
|
color === 'yellow' && 'bg-yellow-400 hover:bg-yellow-500',
|
2022-01-02 06:27:58 +00:00
|
|
|
color === 'blue' && 'bg-blue-400 hover:bg-blue-500',
|
2021-12-16 00:02:15 +00:00
|
|
|
color === 'gray' && 'text-gray-700 bg-gray-300 hover:bg-gray-400',
|
2021-12-10 14:56:17 +00:00
|
|
|
className
|
|
|
|
)}
|
|
|
|
onClick={onClick}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</button>
|
|
|
|
)
|
|
|
|
}
|