Skip to content

Commit

Permalink
fix: fitler search params
Browse files Browse the repository at this point in the history
  • Loading branch information
tom1145 committed May 28, 2024
1 parent 424c1d0 commit b2a4ca1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
6 changes: 1 addition & 5 deletions src/@utils/aquarius/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ export function getFilterTerm(
export function generateBaseQuery(
baseQueryParams: BaseQueryParams
): SearchQuery {
const filters: unknown[] = [
getFilterTerm('_index', 'aquarius')
// getFilterTerm('metadata.type', 'dataset'),
// getFilterTerm('services.type', 'access')
]
const filters: unknown[] = [getFilterTerm('_index', 'aquarius')]
baseQueryParams.filters && filters.push(...baseQueryParams.filters)
baseQueryParams.chainIds &&
filters.push(getFilterTerm('chainId', baseQueryParams.chainIds))
Expand Down
8 changes: 7 additions & 1 deletion src/components/Home/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { ReactElement, useEffect, useState } from 'react'
import Button from '@shared/atoms/Button'
import Bookmarks from './Bookmarks'
import { generateBaseQuery } from '@utils/aquarius'
import { generateBaseQuery, getFilterTerm } from '@utils/aquarius'
import { useUserPreferences } from '@context/UserPreferences'
import { SortTermOptions } from '../../@types/aquarius/SearchQuery'
import TopSales from './TopSales'
Expand All @@ -19,12 +19,18 @@ export default function HomePage(): ReactElement {

const [queryMostAllocation, setQueryMostAllocation] = useState<SearchQuery>()

const filterDatasets: unknown[] = [
getFilterTerm('metadata.type', 'dataset'),
getFilterTerm('services.type', 'access')
]

useEffect(() => {
const baseParams = {
chainIds,
esPaginationOptions: {
size: 6
},
filters: filterDatasets,
sortOptions: {
sortBy: SortTermOptions.Created
} as SortOptions
Expand Down
7 changes: 6 additions & 1 deletion src/components/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ export default function SearchPage({
[router]
)

const parsedWithFilters = {
...parsed,
serviceType: 'access',
accessType: 'dataset'
}
const fetchAssets = useCallback(
async (parsed: queryString.ParsedQuery<string>, chainIds: number[]) => {
setLoading(true)
Expand All @@ -76,7 +81,7 @@ export default function SearchPage({

useEffect(() => {
if (!parsed || !chainIds) return
fetchAssets(parsed, chainIds)
fetchAssets(parsedWithFilters, chainIds)
}, [parsed, chainIds, newCancelToken, fetchAssets])

return (
Expand Down

0 comments on commit b2a4ca1

Please sign in to comment.