From 24e873b6de92716583113f07de294d193e187b0e Mon Sep 17 00:00:00 2001 From: jahooma Date: Mon, 3 Jan 2022 12:56:02 -0600 Subject: [PATCH] Show "sold for" under sale price / payout column. Outcome label to new file --- web/components/bets-list.tsx | 57 ++++++++------------------------ web/components/outcome-label.tsx | 26 +++++++++++++++ 2 files changed, 40 insertions(+), 43 deletions(-) create mode 100644 web/components/outcome-label.tsx diff --git a/web/components/bets-list.tsx b/web/components/bets-list.tsx index 0d0f588f..c7f8cc86 100644 --- a/web/components/bets-list.tsx +++ b/web/components/bets-list.tsx @@ -24,6 +24,7 @@ import { import clsx from 'clsx' import { cloudFunction } from '../lib/firebase/api-call' import { ConfirmationButton } from './confirmation-button' +import { OutcomeLabel, YesLabel, NoLabel } from './outcome-label' export function BetsList(props: { user: User }) { const { user } = props @@ -302,26 +303,21 @@ function BetRow(props: { bet: Bet; contract: Contract; sale?: Bet }) { {formatWithCommas(shares)} - {bet.isSold - ? 'N/A' - : formatMoney( - isResolved - ? resolvedPayout(contract, bet) - : bet.sale - ? bet.sale.amount ?? 0 - : calculateSaleAmount(contract, bet) - )} + {sale ? ( + <>SOLD for {formatMoney(Math.abs(sale.amount))} + ) : ( + formatMoney( + isResolved + ? resolvedPayout(contract, bet) + : calculateSaleAmount(contract, bet) + ) + )} - {sale ? ( - SOLD for {formatMoney(Math.abs(sale.amount))} - ) : ( - !isResolved && - !isSold && ( - - - - ) + {!isResolved && !isSold && ( + + + )} ) @@ -358,28 +354,3 @@ function SellButton(props: { contract: Contract; bet: Bet }) { ) } - -function OutcomeLabel(props: { outcome: 'YES' | 'NO' | 'CANCEL' | 'MKT' }) { - const { outcome } = props - - if (outcome === 'YES') return - if (outcome === 'NO') return - if (outcome === 'MKT') return - return -} - -function YesLabel() { - return YES -} - -function NoLabel() { - return NO -} - -function CancelLabel() { - return N/A -} - -function MarketLabel() { - return MKT -} diff --git a/web/components/outcome-label.tsx b/web/components/outcome-label.tsx new file mode 100644 index 00000000..1eb8ac4f --- /dev/null +++ b/web/components/outcome-label.tsx @@ -0,0 +1,26 @@ +export function OutcomeLabel(props: { + outcome: 'YES' | 'NO' | 'CANCEL' | 'MKT' +}) { + const { outcome } = props + + if (outcome === 'YES') return + if (outcome === 'NO') return + if (outcome === 'MKT') return + return +} + +export function YesLabel() { + return YES +} + +export function NoLabel() { + return NO +} + +export function CancelLabel() { + return N/A +} + +export function MarketLabel() { + return MKT +}