Skip to content

Commit 6695fec

Browse files
committed
feat: navigate to results page on detail search submit
Build a URLSearchParams from the current search values and push to /heritages/results when the sub-header form is submitted so submissions from the detail page reach the results view instead of staying in place.
1 parent cff933d commit 6695fec

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

client/src/app/features/top/components/heritage-detail/HeritageDetailLayout.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useState, useEffect } from "react";
2+
import { useNavigate } from "react-router-dom";
23
import type { WorldHeritageDetailVm } from "../../../../../domain/types.ts";
34
import type { Locale } from "../../../../../domain/criteria";
45
import { HeritageSubHeader } from "../HeritageSubHeader.tsx";
@@ -100,10 +101,20 @@ function KeyExamInfo({ item }: { item: WorldHeritageDetailVm }) {
100101
export function HeritageDetailLayout({ item, locale, toggleLocale }: Props) {
101102
const [search, setSearch] = useState<SearchValues>(DEFAULT_SEARCH);
102103
const setLabel = useSetBreadcrumbLabel();
104+
const navigate = useNavigate();
103105

104106
const handleSubmit = (q: Partial<SearchValues>) => {
105107
const next = { ...search, ...q };
106108
setSearch(next);
109+
110+
const params = new URLSearchParams();
111+
if (next.keyword) params.set("search_query", next.keyword);
112+
if (next.region) params.set("region", next.region);
113+
if (next.category) params.set("category", next.category);
114+
if (next.yearInscribedFrom) params.set("year_inscribed_from", next.yearInscribedFrom);
115+
if (next.yearInscribedTo) params.set("year_inscribed_to", next.yearInscribedTo);
116+
117+
navigate(`/heritages/results?${params.toString()}`);
107118
};
108119

109120
useEffect(() => {

0 commit comments

Comments
 (0)