Skip to content

Commit

Permalink
UseBbox returns a bounds props instead of bboxSate
Browse files Browse the repository at this point in the history
  • Loading branch information
dtrucs committed Oct 17, 2024
1 parent 318adec commit e0d8684
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
13 changes: 11 additions & 2 deletions frontend/src/components/pages/search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const SearchUI: React.FC<Props> = ({ 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)');

Expand Down Expand Up @@ -75,7 +75,16 @@ export const SearchUI: React.FC<Props> = ({ 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);

Expand Down
10 changes: 5 additions & 5 deletions frontend/src/components/pages/search/components/useBbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string | null>(null);
const [bounds, setBboxState] = useState<LatLngBounds | null>(null);

const handleMoveMap = (bounds: LatLngBounds) => {
if (getGlobalConfig().enableSearchByMap) setBboxState(bounds.toBBoxString());
const handleMoveMap = (nextBounds: LatLngBounds) => {
if (getGlobalConfig().enableSearchByMap) setBboxState(nextBounds);
};

return {
bboxState,
bounds,
handleMoveMap,
};
};
Expand Down

0 comments on commit e0d8684

Please sign in to comment.