Add sort by close time
This commit is contained in:
parent
37b8cc9687
commit
03592f9c3e
|
@ -37,7 +37,7 @@ import {
|
||||||
resolvedPayout,
|
resolvedPayout,
|
||||||
} from '../../common/calculate'
|
} from '../../common/calculate'
|
||||||
|
|
||||||
type BetSort = 'newest' | 'profit' | 'settled' | 'value'
|
type BetSort = 'newest' | 'profit' | 'resolutionTime' | 'value' | 'closeTime'
|
||||||
type BetFilter = 'open' | 'closed' | 'resolved' | 'all'
|
type BetFilter = 'open' | 'closed' | 'resolved' | 'all'
|
||||||
|
|
||||||
export function BetsList(props: { user: User }) {
|
export function BetsList(props: { user: User }) {
|
||||||
|
@ -108,7 +108,8 @@ export function BetsList(props: { user: User }) {
|
||||||
value: (c) => contractsCurrentValue[c.id],
|
value: (c) => contractsCurrentValue[c.id],
|
||||||
newest: (c) =>
|
newest: (c) =>
|
||||||
Math.max(...contractBets[c.id].map((bet) => bet.createdTime)),
|
Math.max(...contractBets[c.id].map((bet) => bet.createdTime)),
|
||||||
settled: (c) => c.resolutionTime ?? 0,
|
resolutionTime: (c) => -(c.resolutionTime ?? c.closeTime ?? Infinity),
|
||||||
|
closeTime: (c) => -(c.closeTime ?? Infinity),
|
||||||
}
|
}
|
||||||
const displayedContracts = _.sortBy(contracts, SORTS[sort])
|
const displayedContracts = _.sortBy(contracts, SORTS[sort])
|
||||||
.reverse()
|
.reverse()
|
||||||
|
@ -173,7 +174,8 @@ export function BetsList(props: { user: User }) {
|
||||||
<option value="value">By value</option>
|
<option value="value">By value</option>
|
||||||
<option value="profit">By profit</option>
|
<option value="profit">By profit</option>
|
||||||
<option value="newest">Most recent</option>
|
<option value="newest">Most recent</option>
|
||||||
<option value="settled">By resolution time</option>
|
<option value="closeTime">Closing soonest</option>
|
||||||
|
<option value="resolutionTime">Resolved soonest</option>
|
||||||
</select>
|
</select>
|
||||||
</Row>
|
</Row>
|
||||||
</Col>
|
</Col>
|
||||||
|
@ -449,7 +451,7 @@ export function ContractBetsTable(props: {
|
||||||
<div className={clsx('overflow-x-auto', className)}>
|
<div className={clsx('overflow-x-auto', className)}>
|
||||||
{amountRedeemed > 0 && (
|
{amountRedeemed > 0 && (
|
||||||
<>
|
<>
|
||||||
<div className="text-gray-500 text-sm pl-2">
|
<div className="pl-2 text-sm text-gray-500">
|
||||||
{amountRedeemed} YES shares and {amountRedeemed} NO shares
|
{amountRedeemed} YES shares and {amountRedeemed} NO shares
|
||||||
automatically redeemed for {formatMoney(amountRedeemed)}.
|
automatically redeemed for {formatMoney(amountRedeemed)}.
|
||||||
</div>
|
</div>
|
||||||
|
@ -459,7 +461,7 @@ export function ContractBetsTable(props: {
|
||||||
|
|
||||||
{!isResolved && amountLoaned > 0 && (
|
{!isResolved && amountLoaned > 0 && (
|
||||||
<>
|
<>
|
||||||
<div className="text-gray-500 text-sm pl-2">
|
<div className="pl-2 text-sm text-gray-500">
|
||||||
You currently have a loan of {formatMoney(amountLoaned)}.
|
You currently have a loan of {formatMoney(amountLoaned)}.
|
||||||
</div>
|
</div>
|
||||||
<Spacer h={4} />
|
<Spacer h={4} />
|
||||||
|
@ -505,7 +507,6 @@ function BetRow(props: { bet: Bet; contract: Contract; saleBet?: Bet }) {
|
||||||
shares,
|
shares,
|
||||||
isSold,
|
isSold,
|
||||||
isAnte,
|
isAnte,
|
||||||
loanAmount,
|
|
||||||
} = bet
|
} = bet
|
||||||
|
|
||||||
const { isResolved, closeTime, mechanism } = contract
|
const { isResolved, closeTime, mechanism } = contract
|
||||||
|
|
Loading…
Reference in New Issue
Block a user