aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/app/AppContext.tsx
diff options
context:
space:
mode:
authorAriel Costas Guerrero <ariel@costas.dev>2025-10-22 00:06:52 +0200
committerAriel Costas Guerrero <ariel@costas.dev>2025-10-22 00:07:11 +0200
commit5d6fd75899e96826f8e8aa0c84f7f186cbc7e471 (patch)
tree811cf377bdbe85a3343aed673a6541efee64e982 /src/frontend/app/AppContext.tsx
parent770f764d55045dae34737a5d6111cc7362330e9a (diff)
Confirm region change, make app name more consistent
Diffstat (limited to 'src/frontend/app/AppContext.tsx')
-rw-r--r--src/frontend/app/AppContext.tsx14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/frontend/app/AppContext.tsx b/src/frontend/app/AppContext.tsx
index 1a9b511..8f47a49 100644
--- a/src/frontend/app/AppContext.tsx
+++ b/src/frontend/app/AppContext.tsx
@@ -7,7 +7,7 @@ import {
type ReactNode,
} from "react";
import { type LngLatLike } from "maplibre-gl";
-import { type RegionId, DEFAULT_REGION, getRegionConfig, isValidRegion } from "./data/RegionConfig";
+import { type RegionId, DEFAULT_REGION, getRegionConfig, isValidRegion, REGIONS } from "./data/RegionConfig";
export type Theme = "light" | "dark" | "system";
type TableStyle = "regular" | "grouped";
@@ -43,10 +43,6 @@ interface AppContextProps {
setRegion: (region: RegionId) => void;
}
-// Coordenadas por defecto centradas en Vigo
-const DEFAULT_CENTER: LngLatLike = [42.229188855975046, -8.72246955783102];
-const DEFAULT_ZOOM = 14;
-
const AppContext = createContext<AppContextProps | undefined>(undefined);
export const AppProvider = ({ children }: { children: ReactNode }) => {
@@ -187,8 +183,8 @@ export const AppProvider = ({ children }: { children: ReactNode }) => {
try {
const parsed = JSON.parse(savedMapState);
return {
- center: parsed.center || DEFAULT_CENTER,
- zoom: parsed.zoom || DEFAULT_ZOOM,
+ center: parsed.center || REGIONS[region].defaultCenter,
+ zoom: parsed.zoom || REGIONS[region].defaultZoom,
userLocation: parsed.userLocation || null,
hasLocationPermission: parsed.hasLocationPermission || false,
};
@@ -197,8 +193,8 @@ export const AppProvider = ({ children }: { children: ReactNode }) => {
}
}
return {
- center: DEFAULT_CENTER,
- zoom: DEFAULT_ZOOM,
+ center: REGIONS[region].defaultCenter,
+ zoom: REGIONS[region].defaultZoom,
userLocation: null,
hasLocationPermission: false,
};