aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/app/AppContext.tsx
diff options
context:
space:
mode:
authorAriel Costas Guerrero <ariel@costas.dev>2025-06-24 16:02:02 +0200
committerAriel Costas Guerrero <ariel@costas.dev>2025-06-24 16:02:02 +0200
commitf65b4e1e0d5648038823962349279be4badc68ed (patch)
tree402635814103fde9060c8710523bb4b11ba0a01d /src/frontend/app/AppContext.tsx
parentdc4a7f316c1e3f3392ffd68b6a432eddd7013868 (diff)
Refactor navigation structure: move NavBar to its own component, implement geolocation handling, and remove unused isWithinVigo function from AppContext.
Diffstat (limited to 'src/frontend/app/AppContext.tsx')
-rw-r--r--src/frontend/app/AppContext.tsx40
1 files changed, 0 insertions, 40 deletions
diff --git a/src/frontend/app/AppContext.tsx b/src/frontend/app/AppContext.tsx
index 7ca85bd..d8db66d 100644
--- a/src/frontend/app/AppContext.tsx
+++ b/src/frontend/app/AppContext.tsx
@@ -113,46 +113,6 @@ export const AppProvider = ({ children }: { children: ReactNode }) => {
};
});
- // Helper: check if coordinates are within Vigo bounds
- function isWithinVigo(lngLat: LngLatLike): boolean {
- let lng: number, lat: number;
- if (Array.isArray(lngLat)) {
- [lng, lat] = lngLat;
- } else if ('lng' in lngLat && 'lat' in lngLat) {
- lng = lngLat.lng;
- lat = lngLat.lat;
- } else {
- return false;
- }
- // Rough bounding box for Vigo
- return lat >= 42.18 && lat <= 42.30 && lng >= -8.78 && lng <= -8.65;
- }
-
- // On app load, if mapPositionMode is 'gps', try to get GPS and set map center
- useEffect(() => {
- if (mapPositionMode === 'gps') {
- if (navigator.geolocation) {
- navigator.geolocation.getCurrentPosition(
- (position) => {
- const { latitude, longitude } = position.coords;
- const coords: LngLatLike = [latitude, longitude];
- if (isWithinVigo(coords)) {
- setMapState(prev => {
- const newState = { ...prev, center: coords, zoom: 16, userLocation: coords };
- localStorage.setItem('mapState', JSON.stringify(newState));
- return newState;
- });
- }
- },
- () => {
- // Ignore error, fallback to last
- }
- );
- }
- }
- // If 'last', do nothing (already loaded from localStorage)
- }, [mapPositionMode]);
-
const setMapCenter = (center: LngLatLike) => {
setMapState(prev => {
const newState = { ...prev, center };