From e18809c8137532f86fc5fc9d44e6641c45b674eb Mon Sep 17 00:00:00 2001 From: James Grugett Date: Mon, 9 May 2022 12:24:46 -0400 Subject: [PATCH] Support search in dev environment --- common/envs/constants.ts | 2 +- web/components/contract-search.tsx | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/common/envs/constants.ts b/common/envs/constants.ts index b87948a7..dc753021 100644 --- a/common/envs/constants.ts +++ b/common/envs/constants.ts @@ -2,7 +2,7 @@ import { DEV_CONFIG } from './dev' import { EnvConfig, PROD_CONFIG } from './prod' 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 = { PROD: PROD_CONFIG, diff --git a/web/components/contract-search.tsx b/web/components/contract-search.tsx index 9451b0d3..b46bee6e 100644 --- a/web/components/contract-search.tsx +++ b/web/components/contract-search.tsx @@ -20,19 +20,23 @@ import { Row } from './layout/row' import { useEffect, useState } from 'react' import { Spacer } from './layout/spacer' import { useRouter } from 'next/router' +import { ENV } from 'common/envs/constants' const searchClient = algoliasearch( 'GJQPAYENIF', '75c28fc084a80e1129d427d470cf41a3' ) +const indexPrefix = ENV === 'DEV' ? 'dev-' : '' +console.log('env', ENV, indexPrefix) + const sortIndexes = [ - { label: 'Newest', value: 'contracts-newest' }, - { label: 'Oldest', value: 'contracts-oldest' }, - { label: 'Most traded', value: 'contracts-most-traded' }, - { label: '24h volume', value: 'contracts-24-hour-vol' }, - { label: 'Close date', value: 'contracts-close-date' }, - { label: 'Resolve date', value: 'contracts-resolve-date' }, + { label: 'Newest', value: indexPrefix + 'contracts-newest' }, + { label: 'Oldest', value: indexPrefix + 'contracts-oldest' }, + { label: 'Most traded', value: indexPrefix + 'contracts-most-traded' }, + { label: '24h volume', value: indexPrefix + 'contracts-24-hour-vol' }, + { label: 'Close date', value: indexPrefix + 'contracts-close-date' }, + { label: 'Resolve date', value: indexPrefix + 'contracts-resolve-date' }, ] type filter = 'open' | 'closed' | 'resolved' | 'all' @@ -53,7 +57,7 @@ export function ContractSearch(props: { const sort = sortIndexes .map(({ value }) => value) - .includes(`contracts-${initialSort ?? ''}`) + .includes(`${indexPrefix}contracts-${initialSort ?? ''}`) ? initialSort : querySortOptions?.defaultSort @@ -61,7 +65,10 @@ export function ContractSearch(props: { if (!sort) return <> return ( - +