diff --git a/frontend/src/components/pages/search/Search.tsx b/frontend/src/components/pages/search/Search.tsx index 6c86567c7..de4952c52 100644 --- a/frontend/src/components/pages/search/Search.tsx +++ b/frontend/src/components/pages/search/Search.tsx @@ -47,7 +47,7 @@ export const SearchUI: React.FC = ({ language }) => { const { subMenuState, selectFilter, hideSubMenu, currentFilterId } = useFilterSubMenu(); const { menuState, displayMenu, hideMenu, filtersList } = useFilterMenu(selectFilter); - const { bboxState, handleMoveMap } = useBbox(); + const { bounds, handleMoveMap } = useBbox(); const isMobile = useMediaPredicate('(max-width: 1024px)'); @@ -75,7 +75,16 @@ export const SearchUI: React.FC = ({ language }) => { mobileMapState, displayMobileMap, hideMobileMap, - } = useTrekResults({ filtersState, textFilterState, bboxState, dateFilter, page }, language); + } = useTrekResults( + { + filtersState, + textFilterState, + bboxState: bounds?.toBBoxString() ?? null, + dateFilter, + page, + }, + language, + ); const { pageTitle, resultsTitle } = useTitle(filtersState, searchResults?.resultsNumber); diff --git a/frontend/src/components/pages/search/components/useBbox.ts b/frontend/src/components/pages/search/components/useBbox.ts index 5502f27f9..8a5e75f5f 100644 --- a/frontend/src/components/pages/search/components/useBbox.ts +++ b/frontend/src/components/pages/search/components/useBbox.ts @@ -3,19 +3,19 @@ import { getGlobalConfig } from 'modules/utils/api.config'; import { useState } from 'react'; interface ReturnType { - bboxState: string | null; + bounds: LatLngBounds | null; handleMoveMap: (bounds: LatLngBounds) => void; } const useBbox = (): ReturnType => { - const [bboxState, setBboxState] = useState(null); + const [bounds, setBboxState] = useState(null); - const handleMoveMap = (bounds: LatLngBounds) => { - if (getGlobalConfig().enableSearchByMap) setBboxState(bounds.toBBoxString()); + const handleMoveMap = (nextBounds: LatLngBounds) => { + if (getGlobalConfig().enableSearchByMap) setBboxState(nextBounds); }; return { - bboxState, + bounds, handleMoveMap, }; };