Show "sold for" under sale price / payout column. Outcome label to new file
This commit is contained in:
parent
a331faa1a7
commit
24e873b6de
|
@ -24,6 +24,7 @@ import {
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import { cloudFunction } from '../lib/firebase/api-call'
|
import { cloudFunction } from '../lib/firebase/api-call'
|
||||||
import { ConfirmationButton } from './confirmation-button'
|
import { ConfirmationButton } from './confirmation-button'
|
||||||
|
import { OutcomeLabel, YesLabel, NoLabel } from './outcome-label'
|
||||||
|
|
||||||
export function BetsList(props: { user: User }) {
|
export function BetsList(props: { user: User }) {
|
||||||
const { user } = props
|
const { user } = props
|
||||||
|
@ -302,26 +303,21 @@ function BetRow(props: { bet: Bet; contract: Contract; sale?: Bet }) {
|
||||||
</td>
|
</td>
|
||||||
<td>{formatWithCommas(shares)}</td>
|
<td>{formatWithCommas(shares)}</td>
|
||||||
<td>
|
<td>
|
||||||
{bet.isSold
|
{sale ? (
|
||||||
? 'N/A'
|
<>SOLD for {formatMoney(Math.abs(sale.amount))}</>
|
||||||
: formatMoney(
|
) : (
|
||||||
isResolved
|
formatMoney(
|
||||||
? resolvedPayout(contract, bet)
|
isResolved
|
||||||
: bet.sale
|
? resolvedPayout(contract, bet)
|
||||||
? bet.sale.amount ?? 0
|
: calculateSaleAmount(contract, bet)
|
||||||
: calculateSaleAmount(contract, bet)
|
)
|
||||||
)}
|
)}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
{sale ? (
|
{!isResolved && !isSold && (
|
||||||
<td>SOLD for {formatMoney(Math.abs(sale.amount))}</td>
|
<td className="text-neutral">
|
||||||
) : (
|
<SellButton contract={contract} bet={bet} />
|
||||||
!isResolved &&
|
</td>
|
||||||
!isSold && (
|
|
||||||
<td className="text-neutral">
|
|
||||||
<SellButton contract={contract} bet={bet} />
|
|
||||||
</td>
|
|
||||||
)
|
|
||||||
)}
|
)}
|
||||||
</tr>
|
</tr>
|
||||||
)
|
)
|
||||||
|
@ -358,28 +354,3 @@ function SellButton(props: { contract: Contract; bet: Bet }) {
|
||||||
</ConfirmationButton>
|
</ConfirmationButton>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function OutcomeLabel(props: { outcome: 'YES' | 'NO' | 'CANCEL' | 'MKT' }) {
|
|
||||||
const { outcome } = props
|
|
||||||
|
|
||||||
if (outcome === 'YES') return <YesLabel />
|
|
||||||
if (outcome === 'NO') return <NoLabel />
|
|
||||||
if (outcome === 'MKT') return <MarketLabel />
|
|
||||||
return <CancelLabel />
|
|
||||||
}
|
|
||||||
|
|
||||||
function YesLabel() {
|
|
||||||
return <span className="text-primary">YES</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
function NoLabel() {
|
|
||||||
return <span className="text-red-400">NO</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
function CancelLabel() {
|
|
||||||
return <span className="text-yellow-400">N/A</span>
|
|
||||||
}
|
|
||||||
|
|
||||||
function MarketLabel() {
|
|
||||||
return <span className="text-blue-400">MKT</span>
|
|
||||||
}
|
|
||||||
|
|
26
web/components/outcome-label.tsx
Normal file
26
web/components/outcome-label.tsx
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
export function OutcomeLabel(props: {
|
||||||
|
outcome: 'YES' | 'NO' | 'CANCEL' | 'MKT'
|
||||||
|
}) {
|
||||||
|
const { outcome } = props
|
||||||
|
|
||||||
|
if (outcome === 'YES') return <YesLabel />
|
||||||
|
if (outcome === 'NO') return <NoLabel />
|
||||||
|
if (outcome === 'MKT') return <MarketLabel />
|
||||||
|
return <CancelLabel />
|
||||||
|
}
|
||||||
|
|
||||||
|
export function YesLabel() {
|
||||||
|
return <span className="text-primary">YES</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
export function NoLabel() {
|
||||||
|
return <span className="text-red-400">NO</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
export function CancelLabel() {
|
||||||
|
return <span className="text-yellow-400">N/A</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
export function MarketLabel() {
|
||||||
|
return <span className="text-blue-400">MKT</span>
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user