Small fixes for limit order table

This commit is contained in:
James Grugett 2022-07-14 21:27:00 -05:00
parent 17c9beca28
commit 590c63e911
2 changed files with 14 additions and 12 deletions

View File

@ -45,7 +45,7 @@ import { useUnfilledBets } from 'web/hooks/use-bets'
import { LimitBet } from 'common/bet' import { LimitBet } from 'common/bet'
import { floatingEqual } from 'common/util/math' import { floatingEqual } from 'common/util/math'
import { Pagination } from './pagination' import { Pagination } from './pagination'
import { LimitBets } from './limit-bets' import { LimitOrderTable } from './limit-bets'
type BetSort = 'newest' | 'profit' | 'closeTime' | 'value' type BetSort = 'newest' | 'profit' | 'closeTime' | 'value'
type BetFilter = 'open' | 'limit_bet' | 'sold' | 'closed' | 'resolved' | 'all' type BetFilter = 'open' | 'limit_bet' | 'sold' | 'closed' | 'resolved' | 'all'
@ -364,18 +364,20 @@ function ContractBets(props: {
{contract.mechanism === 'cpmm-1' && limitBets.length > 0 && ( {contract.mechanism === 'cpmm-1' && limitBets.length > 0 && (
<> <>
<div className="bg-gray-50 px-4 py-2">Your limit orders</div> <div className="max-w-md">
<LimitBets <div className="bg-gray-50 px-4 py-2">Limit orders</div>
className="max-w-md px-2 py-0 sm:px-4" <LimitOrderTable
contract={contract} contract={contract}
bets={limitBets} limitBets={limitBets}
hideLabel isYou={true}
/> />
</div>
</> </>
)} )}
<Spacer h={4} /> <Spacer h={4} />
<div className="bg-gray-50 px-4 py-2">Bets</div>
<ContractBetsTable <ContractBetsTable
contract={contract} contract={contract}
bets={bets} bets={bets}

View File

@ -16,7 +16,6 @@ import { BinaryOutcomeLabel, PseudoNumericOutcomeLabel } from './outcome-label'
export function LimitBets(props: { export function LimitBets(props: {
contract: CPMMBinaryContract | PseudoNumericContract contract: CPMMBinaryContract | PseudoNumericContract
bets: LimitBet[] bets: LimitBet[]
hideLabel?: boolean
className?: string className?: string
}) { }) {
const { contract, bets, className } = props const { contract, bets, className } = props
@ -67,20 +66,21 @@ export function LimitBets(props: {
) )
} }
function LimitOrderTable(props: { export function LimitOrderTable(props: {
limitBets: LimitBet[] limitBets: LimitBet[]
contract: CPMMBinaryContract | PseudoNumericContract contract: CPMMBinaryContract | PseudoNumericContract
isYou: boolean isYou: boolean
}) { }) {
const { limitBets, contract, isYou } = props const { limitBets, contract, isYou } = props
const isPseudoNumeric = contract.outcomeType === 'PSEUDO_NUMERIC'
return ( return (
<table className="table-compact table w-full rounded text-gray-500"> <table className="table-compact table w-full rounded text-gray-500">
<thead> <thead>
{!isYou && <th>User</th>} {!isYou && <th></th>}
<th>Outcome</th> <th>Outcome</th>
<th>Amount</th> <th>Amount</th>
<th>Prob</th> <th>{isPseudoNumeric ? 'Value' : 'Prob'}</th>
{isYou && <th></th>} {isYou && <th></th>}
</thead> </thead>
<tbody> <tbody>