markets: make 24hr vol default sort

This commit is contained in:
mantikoros 2022-01-27 12:48:39 -06:00
parent 9764a03189
commit d2e78eb5de

View File

@ -1,30 +1,16 @@
import _ from 'lodash'
import { ContractsGrid, SearchableGrid } from '../components/contracts-list' import { ContractsGrid, SearchableGrid } from '../components/contracts-list'
import { Spacer } from '../components/layout/spacer'
import { Page } from '../components/page' import { Page } from '../components/page'
import { SEO } from '../components/SEO' import { SEO } from '../components/SEO'
import { Title } from '../components/title' import { Title } from '../components/title'
import { useContracts } from '../hooks/use-contracts' import { useContracts } from '../hooks/use-contracts'
import { useQueryAndSortParams } from '../hooks/use-sort-and-query-params' import { useQueryAndSortParams } from '../hooks/use-sort-and-query-params'
import { import { Contract, listAllContracts } from '../lib/firebase/contracts'
Contract,
getClosingSoonContracts,
getHotContracts,
listAllContracts,
} from '../lib/firebase/contracts'
export async function getStaticProps() { export async function getStaticProps() {
const [contracts, hotContracts, closingSoonContracts] = await Promise.all([ const contracts = await listAllContracts().catch((_) => [])
listAllContracts().catch((_) => []),
getHotContracts().catch(() => []),
getClosingSoonContracts().catch(() => []),
])
return { return {
props: { props: {
contracts, contracts,
hotContracts,
closingSoonContracts,
}, },
revalidate: 60, // regenerate after a minute revalidate: 60, // regenerate after a minute
@ -32,15 +18,11 @@ export async function getStaticProps() {
} }
// TODO: Rename endpoint to "Explore" // TODO: Rename endpoint to "Explore"
export default function Markets(props: { export default function Markets(props: { contracts: Contract[] }) {
contracts: Contract[] const contracts = useContracts() ?? props.contracts ?? []
hotContracts: Contract[]
closingSoonContracts: Contract[]
}) {
const contracts = useContracts() ?? props.contracts
const { hotContracts, closingSoonContracts } = props
const { query, setQuery, sort, setSort } = useQueryAndSortParams({ const { query, setQuery, sort, setSort } = useQueryAndSortParams({
defaultSort: 'most-traded', defaultSort: '24-hour-vol',
}) })
return ( return (