diff --git a/web/frontend/app/features/breweries/components/NearbyBreweriesSection.tsx b/web/frontend/app/features/breweries/components/NearbyBreweriesSection.tsx index 23d3c0c7..6660222d 100644 --- a/web/frontend/app/features/breweries/components/NearbyBreweriesSection.tsx +++ b/web/frontend/app/features/breweries/components/NearbyBreweriesSection.tsx @@ -10,7 +10,10 @@ import type { NearbyMapPin } from './NearbyBreweryMap'; const NearbyBreweryMap = lazy(() => import('./NearbyBreweryMap')); const MAP_PLACEHOLDER_CLASS = 'min-h-[30rem] h-full w-full rounded-box bg-base-300'; -const RADIUS_METRES = 120_000; +const DEFAULT_RADIUS_KM = 120; +const MIN_RADIUS_KM = 10; +const MAX_RADIUS_KM = 150; +const RADIUS_STEP_KM = 10; export interface FeaturedPin { id: string; @@ -49,6 +52,7 @@ const NearbyBreweriesSection = ({ const [userLocation, setUserLocation] = useState(null); const [locationLabel, setLocationLabel] = useState('your location'); const [geoAttempted, setGeoAttempted] = useState(false); + const [radiusKm, setRadiusKm] = useState(DEFAULT_RADIUS_KM); const fetcher = useFetcher(); const requestGeolocation = () => { @@ -78,10 +82,10 @@ const NearbyBreweriesSection = ({ useEffect(() => { if (!center) return; fetcher.load( - `/breweries/nearby?latitude=${center[0]}&longitude=${center[1]}&rangeInMetres=${RADIUS_METRES}`, + `/breweries/nearby?latitude=${center[0]}&longitude=${center[1]}&rangeInMetres=${radiusKm * 1000}`, ); // eslint-disable-next-line react-hooks/exhaustive-deps - }, [center?.[0], center?.[1]]); + }, [center?.[0], center?.[1], radiusKm]); const nearby: SimplifiedBrewery[] = fetcher.data?.breweries ?? []; const withDistance = center @@ -120,16 +124,31 @@ const NearbyBreweriesSection = ({

Breweries near you

{center - ? `${withDistance.length} within ${RADIUS_METRES / 1000} km of ${centerLabel}` + ? `${withDistance.length} within ${radiusKm} km of ${centerLabel}` : 'Finding breweries near you…'}
+ {withDistance.length === 0 && center && (

- No partner breweries within {RADIUS_METRES / 1000} km. + No partner breweries within {radiusKm} km.

)} {withDistance.map(({ brewery, distanceMetres }) => (