Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix search page #1297

Merged
merged 3 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions frontend/src/components/pages/details/useDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export const useDetails = (
language: string,
) => {
const id = isUrlString(slug) ? slug.split('-')[0] : '';
const path = isUrlString(slug) ? decodeURI(slug) : '';

const commonDictionaries = useQueryCommonDictionaries(language);

Expand Down Expand Up @@ -108,7 +107,6 @@ export const useDetails = (
mobileMapState,
displayMobileMap,
hideMobileMap,
path,
sectionRef,
mapId,
setMapId,
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/components/pages/flatPage/useFlatPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { getActivitySuggestions } from 'modules/activitySuggestions/connector';

export const useFlatPage = (flatPageUrl: string | undefined) => {
const language = useRouter().locale ?? getDefaultLanguage();
const path = isUrlString(flatPageUrl) ? decodeURI(flatPageUrl) : '';
const id = isUrlString(flatPageUrl) ? flatPageUrl.split('-')[0] : '';

const commonDictionaries = useQueryCommonDictionaries(language);
Expand Down Expand Up @@ -47,6 +46,5 @@ export const useFlatPage = (flatPageUrl: string | undefined) => {
refetch,
isLoading,
error,
path,
};
};
12 changes: 7 additions & 5 deletions frontend/src/components/pages/search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,16 @@ export const SearchUI: React.FC<Props> = ({ language }) => {
} = useTextFilter();

const { dateFilter, setDateFilter } = useDateFilter();
const { searchBbox, setPoints, setSearchBbox, isNavigatedByBrowser } = useListAndMapContext();

const bboxState = bounds ?? (isNavigatedByBrowser ? searchBbox : null);

const {
searchResults,
isLoading,
isError,
refetch,
isFetching,
isFetchingNextPage,
fetchNextPage,
hasNextPage,
Expand All @@ -79,7 +83,7 @@ export const SearchUI: React.FC<Props> = ({ language }) => {
{
filtersState,
textFilterState,
bboxState: bounds?.toBBoxString() ?? null,
bboxState: bboxState?.toBBoxString() ?? null,
dateFilter,
page,
},
Expand All @@ -93,8 +97,6 @@ export const SearchUI: React.FC<Props> = ({ language }) => {
language,
);

const { setPoints, setSearchBbox, isNavigatedByBrowser } = useListAndMapContext();

useEffect(() => {
if (mapResults) {
setPoints(mapResults);
Expand Down Expand Up @@ -216,14 +218,14 @@ export const SearchUI: React.FC<Props> = ({ language }) => {

<InfiniteScroll
dataLength={searchResults?.results.length ?? 0}
next={fetchNextPage}
next={() => !isFetching && fetchNextPage()}
hasMore={Boolean(hasNextPage)}
loader={
<div className={`relative my-10 ${isFetchingNextPage ? 'h-10' : ''}`}>
<Loader loaded={!isFetchingNextPage} />
</div>
}
scrollableTarget="search_resultCardList"
scrollableTarget="body"
>
{searchResults?.results.map(searchResult => {
return (
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/pages/search/hooks/useTrekResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export const useTrekResults = (
fetchNextPage,
hasNextPage,
hasPreviousPage,
isFetching,
isFetchingNextPage,
} = useInfiniteQuery<SearchResults, Error>({
queryKey: [
Expand Down Expand Up @@ -145,6 +146,7 @@ export const useTrekResults = (
isLoading,
isError,
refetch,
isFetching,
isFetchingNextPage,
fetchNextPage,
hasNextPage,
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/components/pages/site/useOutdoorCourse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export const useOutdoorCourse = (
language: string,
) => {
const id = isUrlString(outdoorCourseUrl) ? outdoorCourseUrl.split('-')[0] : '';
const path = isUrlString(outdoorCourseUrl) ? decodeURI(outdoorCourseUrl) : '';

const commonDictionaries = useQueryCommonDictionaries(language);

Expand Down Expand Up @@ -50,10 +49,8 @@ export const useOutdoorCourse = (
mobileMapState,
displayMobileMap,
hideMobileMap,
path,
sectionsReferences,
sectionsPositions,

sectionRef,
};
};
2 changes: 0 additions & 2 deletions frontend/src/components/pages/site/useOutdoorSite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { DetailsSections } from '../details/useDetails';

export const useOutdoorSite = (outdoorSiteUrl: string | string[] | undefined, language: string) => {
const id = isUrlString(outdoorSiteUrl) ? outdoorSiteUrl.split('-')[0] : '';
const path = isUrlString(outdoorSiteUrl) ? decodeURI(outdoorSiteUrl) : '';

const commonDictionaries = useQueryCommonDictionaries(language);

Expand Down Expand Up @@ -51,7 +50,6 @@ export const useOutdoorSite = (outdoorSiteUrl: string | string[] | undefined, la
mobileMapState,
displayMobileMap,
hideMobileMap,
path,
sectionRef,
mapId,
setMapId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export const useTouristicContent = (
const isTouristicContentUrlString = isUrlString(touristicContentUrl);

const id = isTouristicContentUrlString ? touristicContentUrl.split('-')[0] : '';
const path = isTouristicContentUrlString ? decodeURI(touristicContentUrl) : '';

const commonDictionaries = useQueryCommonDictionaries(language);

Expand Down Expand Up @@ -52,7 +51,6 @@ export const useTouristicContent = (
mobileMapState,
displayMobileMap,
hideMobileMap,
path,
sectionsReferences,
sectionsPositions,
sectionRef,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export const useTouristicEvent = (
language: string,
) => {
const id = isUrlString(touristicEventUrl) ? touristicEventUrl.split('-')[0] : '';
const path = isUrlString(touristicEventUrl) ? decodeURI(touristicEventUrl) : '';

const commonDictionaries = useQueryCommonDictionaries(language);

Expand Down Expand Up @@ -49,7 +48,6 @@ export const useTouristicEvent = (
mobileMapState,
displayMobileMap,
hideMobileMap,
path,
sectionsReferences,
sectionsPositions,
sectionRef,
Expand Down
Loading