minor changes

This commit is contained in:
2025-11-10 22:36:18 +01:00
parent 545074a3b8
commit a76aa95d09

View File

@@ -8,6 +8,7 @@ import {
useReactTable
} from '@tanstack/react-table';
import { haversineDistanceKm } from '../utils/distance';
import { inferLocationLabel } from '../utils/locationLabel';
import NotificationPanel from './NotificationPanel';
const REGION_STORAGE_KEY = 'storeWatchRegionSelection';
@@ -130,6 +131,41 @@ const StoreWatchPage = ({
const combinedLocationError = locationError || locationPromptError;
const locationActionBusy = locationSaving || locationPromptPending;
const formatCoordinate = (value) => (Number.isFinite(value) ? Number(value).toFixed(4) : '');
const aggregatedRegionStores = useMemo(() => {
const list = [];
Object.values(storesByRegion).forEach((entry) => {
if (Array.isArray(entry?.stores)) {
entry.stores.forEach((store) => {
if (store) {
list.push(store);
}
});
}
});
return list;
}, [storesByRegion]);
const proximityLabel = useMemo(() => {
if (!userLocation) {
return null;
}
return inferLocationLabel(userLocation, aggregatedRegionStores);
}, [userLocation, aggregatedRegionStores]);
const displayLocation = useMemo(() => {
if (!userLocation) {
return null;
}
if (userLocation.label) {
return userLocation;
}
if (proximityLabel) {
return {
...userLocation,
label: proximityLabel.label,
labelDistanceKm: proximityLabel.distanceKm
};
}
return userLocation;
}, [userLocation, proximityLabel]);
useEffect(() => {
if (typeof window === 'undefined') {
@@ -893,7 +929,7 @@ const StoreWatchPage = ({
{notificationPanelOpen && notificationProps && (
<NotificationPanel
{...notificationProps}
location={userLocation}
location={displayLocation}
locationLoading={locationLoading}
locationSaving={locationActionBusy}
locationError={combinedLocationError}