Skip to content

Commit

Permalink
Fix the call of popupResult in map Popup component
Browse files Browse the repository at this point in the history
  • Loading branch information
dtrucs committed Dec 6, 2023
1 parent f407e9b commit 7b73b98
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion frontend/src/components/Map/components/Popup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ const PopupContent: React.FC<PropsPC> = ({ showButton, id, type, parentId, conte
let isLoading = false;
let trekPopupResult = null;

const popupResult = usePopupResult(id.toString(), true, type);

if (!content && type) {
const popupResult = usePopupResult(id.toString(), true, type);
isLoading = popupResult.isLoading;
trekPopupResult = popupResult.trekPopupResult;
} else {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/Map/hooks/usePopupResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { getOutdoorSitePopupResult } from '../../../modules/outdoorSite/connecto
export const usePopupResult = (
id: string,
shouldFetch: boolean,
type: 'TREK' | 'TOURISTIC_CONTENT' | 'OUTDOOR_SITE' | 'TOURISTIC_EVENT',
type: 'TREK' | 'TOURISTIC_CONTENT' | 'OUTDOOR_SITE' | 'TOURISTIC_EVENT' | null,
) => {
const language = useRouter().locale ?? getDefaultLanguage();
const commonDictionaries = queryCommonDictionaries(language);
Expand All @@ -31,7 +31,7 @@ export const usePopupResult = (
const { data: trekPopupResult, isLoading } = useQuery<PopupResult, Error>(
['popupResult', id, language],
fetchData,
{ enabled: shouldFetch && commonDictionaries !== undefined },
{ enabled: type !== null && shouldFetch && commonDictionaries !== undefined },
);

return {
Expand Down

0 comments on commit 7b73b98

Please sign in to comment.