Add portfolio filter for limit bets.

This commit is contained in:
James Grugett 2022-07-10 22:15:07 -05:00
parent 9586e81e95
commit 99fcfa6be7
2 changed files with 5 additions and 2 deletions

View File

@ -16,7 +16,6 @@ import {
formatWithCommas, formatWithCommas,
} from 'common/util/format' } from 'common/util/format'
import { getBinaryCpmmBetInfo } from 'common/new-bet' import { getBinaryCpmmBetInfo } from 'common/new-bet'
import { Title } from './title'
import { User } from 'web/lib/firebase/users' import { User } from 'web/lib/firebase/users'
import { Bet, LimitBet } from 'common/bet' import { Bet, LimitBet } from 'common/bet'
import { APIError, placeBet } from 'web/lib/firebase/api' import { APIError, placeBet } from 'web/lib/firebase/api'

View File

@ -48,7 +48,7 @@ import { Pagination } from './pagination'
import { LimitBets } from './limit-bets' import { LimitBets } from './limit-bets'
type BetSort = 'newest' | 'profit' | 'closeTime' | 'value' type BetSort = 'newest' | 'profit' | 'closeTime' | 'value'
type BetFilter = 'open' | 'sold' | 'closed' | 'resolved' | 'all' type BetFilter = 'open' | 'limit_bet' | 'sold' | 'closed' | 'resolved' | 'all'
const CONTRACTS_PER_PAGE = 20 const CONTRACTS_PER_PAGE = 20
@ -110,6 +110,7 @@ export function BetsList(props: {
open: (c) => !(FILTERS.closed(c) || FILTERS.resolved(c)), open: (c) => !(FILTERS.closed(c) || FILTERS.resolved(c)),
all: () => true, all: () => true,
sold: () => true, sold: () => true,
limit_bet: (c) => FILTERS.open(c),
} }
const SORTS: Record<BetSort, (c: Contract) => number> = { const SORTS: Record<BetSort, (c: Contract) => number> = {
profit: (c) => contractsMetrics[c.id].profit, profit: (c) => contractsMetrics[c.id].profit,
@ -130,6 +131,8 @@ export function BetsList(props: {
const { hasShares } = contractsMetrics[c.id] const { hasShares } = contractsMetrics[c.id]
if (filter === 'sold') return !hasShares if (filter === 'sold') return !hasShares
if (filter === 'limit_bet')
return (contractBets[c.id] ?? []).some((b) => b.limitProb !== undefined)
return hasShares return hasShares
}) })
const displayedContracts = filteredContracts.slice(start, end) const displayedContracts = filteredContracts.slice(start, end)
@ -185,6 +188,7 @@ export function BetsList(props: {
onChange={(e) => setFilter(e.target.value as BetFilter)} onChange={(e) => setFilter(e.target.value as BetFilter)}
> >
<option value="open">Open</option> <option value="open">Open</option>
<option value="limit_bet">Limit bets</option>
<option value="sold">Sold</option> <option value="sold">Sold</option>
<option value="closed">Closed</option> <option value="closed">Closed</option>
<option value="resolved">Resolved</option> <option value="resolved">Resolved</option>