From b2a4ca1c206a13fcb0211f21c85b90902702554f Mon Sep 17 00:00:00 2001 From: tom1145 Date: Tue, 28 May 2024 16:28:18 +0300 Subject: [PATCH] fix: fitler search params --- src/@utils/aquarius/index.ts | 6 +----- src/components/Home/index.tsx | 8 +++++++- src/components/Search/index.tsx | 7 ++++++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/@utils/aquarius/index.ts b/src/@utils/aquarius/index.ts index 7fd1dc6676..c3a7ff0f99 100644 --- a/src/@utils/aquarius/index.ts +++ b/src/@utils/aquarius/index.ts @@ -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)) diff --git a/src/components/Home/index.tsx b/src/components/Home/index.tsx index e6d80f2eae..af2ab4ed01 100644 --- a/src/components/Home/index.tsx +++ b/src/components/Home/index.tsx @@ -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' @@ -19,12 +19,18 @@ export default function HomePage(): ReactElement { const [queryMostAllocation, setQueryMostAllocation] = useState() + 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 diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 7979e3a9a7..52421d11fa 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -55,6 +55,11 @@ export default function SearchPage({ [router] ) + const parsedWithFilters = { + ...parsed, + serviceType: 'access', + accessType: 'dataset' + } const fetchAssets = useCallback( async (parsed: queryString.ParsedQuery, chainIds: number[]) => { setLoading(true) @@ -76,7 +81,7 @@ export default function SearchPage({ useEffect(() => { if (!parsed || !chainIds) return - fetchAssets(parsed, chainIds) + fetchAssets(parsedWithFilters, chainIds) }, [parsed, chainIds, newCancelToken, fetchAssets]) return (