minor changes
This commit is contained in:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user