diff --git a/web/components/contract-search.tsx b/web/components/contract-search.tsx index 919cce86..331dcb80 100644 --- a/web/components/contract-search.tsx +++ b/web/components/contract-search.tsx @@ -48,6 +48,7 @@ import { Title } from './title' export const SORTS = [ { label: 'Newest', value: 'newest' }, { label: 'Trending', value: 'score' }, + { label: 'Daily trending', value: 'daily-score' }, { label: '24h volume', value: '24-hour-vol' }, { label: 'Last updated', value: 'last-updated' }, { label: 'Closing soon', value: 'close-date' }, @@ -88,6 +89,7 @@ export function ContractSearch(props: { hideGroupLink?: boolean hideQuickBet?: boolean noLinkAvatar?: boolean + showProbChange?: boolean } headerClassName?: string persistPrefix?: string @@ -128,6 +130,7 @@ export function ContractSearch(props: { numPages: 1, pages: [] as Contract[][], showTime: null as ShowTime | null, + showProbChange: false, }, !persistPrefix ? undefined @@ -181,8 +184,9 @@ export function ContractSearch(props: { const newPage = results.hits as any as Contract[] const showTime = sort === 'close-date' || sort === 'resolve-date' ? sort : null + const showProbChange = sort === 'daily-score' const pages = freshQuery ? [newPage] : [...state.pages, newPage] - setState({ numPages: results.nbPages, pages, showTime }) + setState({ numPages: results.nbPages, pages, showTime, showProbChange }) if (freshQuery && isWholePage) window.scrollTo(0, 0) } } @@ -200,6 +204,12 @@ export function ContractSearch(props: { }, 100) ).current + const updatedCardUIOptions = useMemo(() => { + if (cardUIOptions?.showProbChange === undefined && state.showProbChange) + return { ...cardUIOptions, showProbChange: true } + return cardUIOptions + }, [cardUIOptions, state.showProbChange]) + const contracts = state.pages .flat() .filter((c) => !additionalFilter?.excludeContractIds?.includes(c.id)) @@ -236,7 +246,7 @@ export function ContractSearch(props: { showTime={state.showTime ?? undefined} onContractClick={onContractClick} highlightOptions={highlightOptions} - cardUIOptions={cardUIOptions} + cardUIOptions={updatedCardUIOptions} /> )}