From 5d6fd75899e96826f8e8aa0c84f7f186cbc7e471 Mon Sep 17 00:00:00 2001 From: Ariel Costas Guerrero Date: Wed, 22 Oct 2025 00:06:52 +0200 Subject: Confirm region change, make app name more consistent --- src/frontend/app/AppContext.tsx | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src/frontend/app/AppContext.tsx') 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(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, }; -- cgit v1.3