Support search in dev environment
This commit is contained in:
parent
d8eed874c1
commit
e18809c813
|
@ -2,7 +2,7 @@ import { DEV_CONFIG } from './dev'
|
||||||
import { EnvConfig, PROD_CONFIG } from './prod'
|
import { EnvConfig, PROD_CONFIG } from './prod'
|
||||||
import { THEOREMONE_CONFIG } from './theoremone'
|
import { THEOREMONE_CONFIG } from './theoremone'
|
||||||
|
|
||||||
const ENV = process.env.NEXT_PUBLIC_FIREBASE_ENV ?? 'PROD'
|
export const ENV = process.env.NEXT_PUBLIC_FIREBASE_ENV ?? 'PROD'
|
||||||
|
|
||||||
const CONFIGS = {
|
const CONFIGS = {
|
||||||
PROD: PROD_CONFIG,
|
PROD: PROD_CONFIG,
|
||||||
|
|
|
@ -20,19 +20,23 @@ import { Row } from './layout/row'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import { Spacer } from './layout/spacer'
|
import { Spacer } from './layout/spacer'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
|
import { ENV } from 'common/envs/constants'
|
||||||
|
|
||||||
const searchClient = algoliasearch(
|
const searchClient = algoliasearch(
|
||||||
'GJQPAYENIF',
|
'GJQPAYENIF',
|
||||||
'75c28fc084a80e1129d427d470cf41a3'
|
'75c28fc084a80e1129d427d470cf41a3'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const indexPrefix = ENV === 'DEV' ? 'dev-' : ''
|
||||||
|
console.log('env', ENV, indexPrefix)
|
||||||
|
|
||||||
const sortIndexes = [
|
const sortIndexes = [
|
||||||
{ label: 'Newest', value: 'contracts-newest' },
|
{ label: 'Newest', value: indexPrefix + 'contracts-newest' },
|
||||||
{ label: 'Oldest', value: 'contracts-oldest' },
|
{ label: 'Oldest', value: indexPrefix + 'contracts-oldest' },
|
||||||
{ label: 'Most traded', value: 'contracts-most-traded' },
|
{ label: 'Most traded', value: indexPrefix + 'contracts-most-traded' },
|
||||||
{ label: '24h volume', value: 'contracts-24-hour-vol' },
|
{ label: '24h volume', value: indexPrefix + 'contracts-24-hour-vol' },
|
||||||
{ label: 'Close date', value: 'contracts-close-date' },
|
{ label: 'Close date', value: indexPrefix + 'contracts-close-date' },
|
||||||
{ label: 'Resolve date', value: 'contracts-resolve-date' },
|
{ label: 'Resolve date', value: indexPrefix + 'contracts-resolve-date' },
|
||||||
]
|
]
|
||||||
|
|
||||||
type filter = 'open' | 'closed' | 'resolved' | 'all'
|
type filter = 'open' | 'closed' | 'resolved' | 'all'
|
||||||
|
@ -53,7 +57,7 @@ export function ContractSearch(props: {
|
||||||
|
|
||||||
const sort = sortIndexes
|
const sort = sortIndexes
|
||||||
.map(({ value }) => value)
|
.map(({ value }) => value)
|
||||||
.includes(`contracts-${initialSort ?? ''}`)
|
.includes(`${indexPrefix}contracts-${initialSort ?? ''}`)
|
||||||
? initialSort
|
? initialSort
|
||||||
: querySortOptions?.defaultSort
|
: querySortOptions?.defaultSort
|
||||||
|
|
||||||
|
@ -61,7 +65,10 @@ export function ContractSearch(props: {
|
||||||
|
|
||||||
if (!sort) return <></>
|
if (!sort) return <></>
|
||||||
return (
|
return (
|
||||||
<InstantSearch searchClient={searchClient} indexName={`contracts-${sort}`}>
|
<InstantSearch
|
||||||
|
searchClient={searchClient}
|
||||||
|
indexName={`${indexPrefix}contracts-${sort}`}
|
||||||
|
>
|
||||||
<Row className="flex-wrap gap-2">
|
<Row className="flex-wrap gap-2">
|
||||||
<SearchBox
|
<SearchBox
|
||||||
className="flex-1"
|
className="flex-1"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user