This commit is contained in:
Andras Schmelczer 2026-05-26 19:45:13 +01:00
parent c645b0f1d4
commit 39ef5c6646
79 changed files with 5660 additions and 2199 deletions

View file

@ -1,7 +1,7 @@
import { Suspense, useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { Trans, useTranslation } from 'react-i18next';
import type { MapFlyToOptions, PostcodeGeometry } from '../../types';
import type { ActualListing, MapFlyToOptions, PostcodeGeometry } from '../../types';
import type { SearchedLocation } from './LocationSearch';
import { useMapData } from '../../hooks/useMapData';
import { usePOIData } from '../../hooks/usePOIData';
@ -25,11 +25,7 @@ import {
import { apiUrl, authHeaders, buildFilterString } from '../../lib/api';
import { useFilterCounts } from '../../hooks/useFilterCounts';
import { trackEvent } from '../../lib/analytics';
import {
INITIAL_VIEW_STATE,
POSTCODE_SEARCH_ZOOM,
POSTCODE_ZOOM_THRESHOLD,
} from '../../lib/consts';
import { INITIAL_VIEW_STATE, POSTCODE_ZOOM_THRESHOLD } from '../../lib/consts';
import type { OverlayId } from '../../lib/overlays';
import { useLicense } from '../../hooks/useLicense';
import { stateToParams } from '../../lib/url-state';
@ -67,6 +63,9 @@ import type { MapFlyTo, MapPageProps } from './map-page/types';
export type { ExportState } from './map-page/types';
type PendingFlyTo = { lat: number; lng: number; zoom: number };
const EMPTY_ACTUAL_LISTINGS: ActualListing[] = [];
declare const __DEV__: boolean;
export default function MapPage({
features,
@ -115,6 +114,7 @@ export default function MapPage({
const [poiPaneOpen, setPoiPaneOpen] = useState(false);
const [overlayPaneOpen, setOverlayPaneOpen] = useState(false);
const [currentLocation, setCurrentLocation] = useState<{ lat: number; lng: number } | null>(null);
const [devActualListingsEnabled, setDevActualListingsEnabled] = useState(true);
const {
filters,
@ -378,7 +378,7 @@ export default function MapPage({
pendingLocationSearchFlyToRef.current = {
lat: markerLat ?? result.latitude,
lng: markerLng ?? result.longitude,
zoom: result.openProperties ? 17 : POSTCODE_SEARCH_ZOOM,
zoom: result.zoom,
};
setMobileDrawerOpen(true);
consumePendingLocationSearchFlyTo();
@ -450,11 +450,20 @@ export default function MapPage({
[filters, features]
);
const actualListingsTravelParam = useMemo(() => buildTravelParam(entries), [entries]);
const { listings: actualListings } = useActualListings(mapData.bounds, {
filterParam: actualListingsFilterParam,
travelParam: actualListingsTravelParam,
shareCode,
});
const actualListingsEnabled = !__DEV__ || devActualListingsEnabled;
const { listings: actualListings } = useActualListings(
actualListingsEnabled ? mapData.bounds : null,
{
filterParam: actualListingsFilterParam,
travelParam: actualListingsTravelParam,
shareCode,
}
);
const visibleActualListings = actualListingsEnabled ? actualListings : EMPTY_ACTUAL_LISTINGS;
const handleToggleActualListings = useCallback(() => {
if (!__DEV__) return;
setDevActualListingsEnabled((enabled) => !enabled);
}, []);
const [isAreaGroupExpanded, toggleAreaGroup] = useCollapsibleGroups(true);
useUrlSync(
@ -798,7 +807,9 @@ export default function MapPage({
onLocationSearched={handleLocationSearchResult}
onCurrentLocationFound={handleCurrentLocationFound}
currentLocation={currentLocation}
actualListings={actualListings}
actualListings={visibleActualListings}
actualListingsEnabled={actualListingsEnabled}
onToggleActualListings={__DEV__ ? handleToggleActualListings : undefined}
travelTimeEntries={entries}
bottomScreenInset={mobileBottomSheetHeight}
onBottomSheetCoveredHeightChange={setMobileBottomSheetHeight}
@ -866,7 +877,9 @@ export default function MapPage({
onLocationSearched={handleLocationSearchResult}
onCurrentLocationFound={handleCurrentLocationFound}
currentLocation={currentLocation}
actualListings={actualListings}
actualListings={visibleActualListings}
actualListingsEnabled={actualListingsEnabled}
onToggleActualListings={__DEV__ ? handleToggleActualListings : undefined}
travelTimeEntries={entries}
densityLabel={densityLabel}
totalCount={hasActiveFilters ? filterCounts.total : undefined}