diff --git a/src/components/templates/Search/index.tsx b/src/components/templates/Search/index.tsx index ae7748357..629a19392 100644 --- a/src/components/templates/Search/index.tsx +++ b/src/components/templates/Search/index.tsx @@ -21,19 +21,20 @@ export default function SearchPage({ }): ReactElement { const { config } = useOcean() const parsed = queryString.parse(location.search) - const { text, tag, page } = parsed + const { text, tags, page } = parsed const [queryResult, setQueryResult] = useState() const [loading, setLoading] = useState() useEffect(() => { async function initSearch() { setLoading(true) + console.log(parsed) const queryResult = await getResults(parsed, config.metadataCacheUri) setQueryResult(queryResult) setLoading(false) } initSearch() - }, [text, tag, page, config.metadataCacheUri]) + }, [text, tags, page, config.metadataCacheUri]) return (
diff --git a/src/components/templates/Search/utils.ts b/src/components/templates/Search/utils.ts index 6f076be2b..0ae7973ea 100644 --- a/src/components/templates/Search/utils.ts +++ b/src/components/templates/Search/utils.ts @@ -8,14 +8,14 @@ export function getSearchQuery( page?: string | string[], offset?: string | string[], text?: string | string[], - tag?: string | string[] + tags?: string | string[] ): SearchQuery { return { page: Number(page) || 1, offset: Number(offset) || 20, query: { text, - tags: tag ? [tag] : undefined + tags: tags ? [tags] : undefined }, sort: { created: -1 @@ -29,14 +29,16 @@ export function getSearchQuery( } export async function getResults( - params: { text?: string; tag?: string; page?: string; offset?: string }, + params: { text?: string; tags?: string; page?: string; offset?: string }, metadataCacheUri: string ): Promise { - const { text, tag, page, offset } = params + const { text, tags, page, offset } = params const metadataCache = new MetadataCache(metadataCacheUri, Logger) + const sQuery = getSearchQuery(page, offset, text, tags) + console.log(sQuery) const queryResult = await metadataCache.queryMetadata( - getSearchQuery(page, offset, text, tag) + getSearchQuery(page, offset, text, tags) ) return queryResult