From 09e42807b3343cc08e92887af701d8b430f90708 Mon Sep 17 00:00:00 2001 From: Mika Munterud Date: Wed, 11 Dec 2024 12:21:15 +0100 Subject: [PATCH] DIGG-439: Removing url params from dataset-series page --- .../entryscape/dataset-series-page/index.tsx | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/features/entryscape/dataset-series-page/index.tsx b/features/entryscape/dataset-series-page/index.tsx index 3da8aa50..f58baabb 100644 --- a/features/entryscape/dataset-series-page/index.tsx +++ b/features/entryscape/dataset-series-page/index.tsx @@ -1,3 +1,4 @@ +import { Entry } from "@entryscape/entrystore-js"; import { useRouter } from "next/router"; import useTranslation from "next-translate/useTranslation"; import { FC, useContext, useEffect, useMemo } from "react"; @@ -8,10 +9,33 @@ import { Heading } from "@/components/typography/heading"; import { createSearchProviderSettings } from "@/features/search/search-page/search-page-entryscape/search-page-provider-settings"; import { SearchResults } from "@/features/search/search-results"; import { EntrystoreContext } from "@/providers/entrystore-provider"; -import SearchProvider, { SearchContext } from "@/providers/search-provider"; +import SearchProvider, { + SearchContext, + SearchContextData, +} from "@/providers/search-provider"; import { SettingsContext } from "@/providers/settings-provider"; import { linkBase } from "@/utilities"; +const SearchSection: FC<{ search: SearchContextData; entry: Entry }> = ({ + search, + entry, +}) => { + useEffect(() => { + if (!search) return; + + // Perform initial search + search + .set({ + page: 0, + query: "", + fetchFacets: true, + }) + .then(() => search.doSearch(false, false, false, false)); + }, [entry]); + + return null; +}; + export const DatasetSeriesPage: FC = () => { const { pathname } = useRouter() || {}; const { env, setBreadcrumb } = useContext(SettingsContext); @@ -32,21 +56,6 @@ export const DatasetSeriesPage: FC = () => { }); }, [pathname, entry]); - useEffect(() => { - // Check if there are no query parameters or if they're empty - if (!router.query.q && !router.query.f) { - // Update URL with default query parameters - router.replace( - { - pathname: router.pathname, - query: { ...router.query, q: "", f: "" }, - }, - undefined, - { shallow: true }, - ); - } - }, [router.isReady]); - const searchProviderSettings = useMemo( () => createSearchProviderSettings(env, lang), [env, lang], @@ -81,6 +90,7 @@ export const DatasetSeriesPage: FC = () => { {(search) => (
+