11import { useState , useEffect } from "react" ;
2+ import { useNavigate } from "react-router-dom" ;
23import type { WorldHeritageDetailVm } from "../../../../../domain/types.ts" ;
34import type { Locale } from "../../../../../domain/criteria" ;
45import { HeritageSubHeader } from "../HeritageSubHeader.tsx" ;
@@ -15,6 +16,7 @@ import { BreadcrumbList } from "@shared/components/BreadcrumbList.tsx";
1516type Props = {
1617 item : WorldHeritageDetailVm ;
1718 locale : Locale ;
19+ toggleLocale : ( ) => void ;
1820} ;
1921
2022const DEFAULT_SEARCH : SearchValues = {
@@ -96,13 +98,23 @@ function KeyExamInfo({ item }: { item: WorldHeritageDetailVm }) {
9698 ) ;
9799}
98100
99- export function HeritageDetailLayout ( { item, locale } : Props ) {
101+ export function HeritageDetailLayout ( { item, locale, toggleLocale } : Props ) {
100102 const [ search , setSearch ] = useState < SearchValues > ( DEFAULT_SEARCH ) ;
101103 const setLabel = useSetBreadcrumbLabel ( ) ;
104+ const navigate = useNavigate ( ) ;
102105
103106 const handleSubmit = ( q : Partial < SearchValues > ) => {
104107 const next = { ...search , ...q } ;
105108 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 ( ) } ` ) ;
106118 } ;
107119
108120 useEffect ( ( ) => {
@@ -115,7 +127,15 @@ export function HeritageDetailLayout({ item, locale }: Props) {
115127 < div className = "min-h-screen bg-zinc-50 text-zinc-900" >
116128 < HeritageSubHeader value = { search } onChange = { setSearch } onSubmit = { handleSubmit } />
117129
118- < HeritageDetailTabs items = { TABS } />
130+ < div className = "mx-auto w-full max-w-6xl px-4 mt-6 md:mt-8 flex items-center justify-between" >
131+ < HeritageDetailTabs items = { TABS } />
132+ < button
133+ onClick = { toggleLocale }
134+ className = "rounded-full border border-zinc-200 px-3 py-1.5 text-xs font-semibold text-zinc-700 hover:bg-zinc-100 shrink-0"
135+ >
136+ { locale === "ja" ? "🇯🇵" : "🇬🇧" }
137+ </ button >
138+ </ div >
119139
120140 < div className = "mx-auto w-full max-w-6xl px-4 mt-4" >
121141 < BreadcrumbList />
@@ -136,7 +156,7 @@ export function HeritageDetailLayout({ item, locale }: Props) {
136156 < div className = "grid gap-6 lg:gap-8 lg:grid-cols-[minmax(0,1fr)_360px] lg:items-start" >
137157 { /* Left: Overview → Gallery */ }
138158 < div className = "space-y-8" id = "content" >
139- < HeritageOverViewSection item = { item } />
159+ < HeritageOverViewSection item = { item } locale = { locale } />
140160 < HeritageGallery images = { item . images } />
141161 </ div >
142162
0 commit comments