From 5d38018a539933625c8ff0c57cbb6beee9538838 Mon Sep 17 00:00:00 2001 From: James Grugett Date: Fri, 6 May 2022 11:39:52 -0400 Subject: [PATCH] Closed sort option --- web/components/contract-search.tsx | 11 +++++++++-- web/hooks/use-sort-and-query-params.tsx | 3 --- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/web/components/contract-search.tsx b/web/components/contract-search.tsx index ca909035..ac6b31e1 100644 --- a/web/components/contract-search.tsx +++ b/web/components/contract-search.tsx @@ -32,6 +32,7 @@ const sortIndexes = [ { label: 'Most traded', value: 'contracts-most-traded' }, { label: '24h volume', value: 'contracts-24-hour-vol' }, { label: 'Closing soon', value: 'contracts-closing-soon' }, + { label: 'Closed', value: 'contracts-closed' }, { label: 'Resolved', value: 'contracts-resolved' }, ] @@ -120,7 +121,11 @@ export function ContractSearchInner(props: { const tag = querySortOptions?.filter?.tag useFilterTag(tag) - if (!creatorId) { + if ( + !creatorId || + index === 'contracts-closed' || + index === 'contracts-resolved' + ) { // eslint-disable-next-line react-hooks/rules-of-hooks useFilterClosed(index) @@ -168,7 +173,9 @@ const useFilterClosed = (index: string) => { const [now] = useState(Date.now()) useRange({ attribute: 'closeTime', - min: index === 'contracts-resolved' ? 0 : now, + min: + index === 'contracts-resolved' || index === 'contracts-closed' ? 0 : now, + max: index === 'contracts-closed' ? now : undefined, }) } diff --git a/web/hooks/use-sort-and-query-params.tsx b/web/hooks/use-sort-and-query-params.tsx index 72c899ad..7a9abb85 100644 --- a/web/hooks/use-sort-and-query-params.tsx +++ b/web/hooks/use-sort-and-query-params.tsx @@ -6,8 +6,6 @@ import { useSearchBox } from 'react-instantsearch-hooks-web' const MARKETS_SORT = 'markets_sort' export type Sort = - | 'creator' - | 'tag' | 'newest' | 'oldest' | 'most-traded' @@ -15,7 +13,6 @@ export type Sort = | 'closing-soon' | 'closed' | 'resolved' - | 'all' export function useInitialQueryAndSort(options?: { defaultSort: Sort