Closed sort option

This commit is contained in:
James Grugett 2022-05-06 11:39:52 -04:00
parent 042fdb3cbe
commit 5d38018a53
2 changed files with 9 additions and 5 deletions

View File

@ -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,
})
}

View File

@ -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