Feat: Geolocation
This commit is contained in:
@@ -9,6 +9,8 @@ import {
|
||||
} from '@tanstack/react-table';
|
||||
import { haversineDistanceKm } from '../utils/distance';
|
||||
|
||||
const REGION_STORAGE_KEY = 'storeWatchRegionSelection';
|
||||
|
||||
const columnHelper = createColumnHelper();
|
||||
|
||||
const ColumnTextFilter = ({ column, placeholder }) => {
|
||||
@@ -48,7 +50,16 @@ const ColumnSelectFilter = ({ column, options }) => {
|
||||
|
||||
const StoreWatchPage = ({ authorizedFetch, knownStores = [], userLocation }) => {
|
||||
const [regions, setRegions] = useState([]);
|
||||
const [selectedRegionId, setSelectedRegionId] = useState('');
|
||||
const [selectedRegionId, setSelectedRegionId] = useState(() => {
|
||||
if (typeof window === 'undefined') {
|
||||
return 'all';
|
||||
}
|
||||
try {
|
||||
return window.localStorage.getItem(REGION_STORAGE_KEY) || 'all';
|
||||
} catch {
|
||||
return 'all';
|
||||
}
|
||||
});
|
||||
const [storesByRegion, setStoresByRegion] = useState({});
|
||||
const [watchList, setWatchList] = useState([]);
|
||||
const [regionLoading, setRegionLoading] = useState(false);
|
||||
@@ -61,6 +72,17 @@ const StoreWatchPage = ({ authorizedFetch, knownStores = [], userLocation }) =>
|
||||
const [sorting, setSorting] = useState([]);
|
||||
const [columnFilters, setColumnFilters] = useState([{ id: 'isOpen', value: 'true' }]);
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window === 'undefined') {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
window.localStorage.setItem(REGION_STORAGE_KEY, selectedRegionId || 'all');
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}, [selectedRegionId]);
|
||||
|
||||
const watchedIds = useMemo(
|
||||
() => new Set(watchList.map((entry) => String(entry.storeId))),
|
||||
[watchList]
|
||||
|
||||
Reference in New Issue
Block a user