feat(navi): config-driven tile source, defaults, and feature flags

Load deployment config from /api/config on startup:
- src/config.js: loader with 3s timeout + hardcoded fallback
- src/hooks/useConfig.js: useConfig() and useFeature() hooks
- MapView.jsx: tile URL, attribution, center, zoom from config
- main.jsx: loads config before first render

Falls back to home profile defaults if backend unavailable.
No visible behavior change — infrastructure for future features.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matt 2026-04-20 23:36:02 +00:00
commit edc5a9788d
4 changed files with 146 additions and 22 deletions

29
src/hooks/useConfig.js Normal file
View file

@ -0,0 +1,29 @@
import { useState, useEffect } from 'react'
import { loadConfig, getConfig, hasFeature } from '../config'
/**
* Hook that returns the deployment config, loading it if needed.
* Components using this will re-render once config is loaded.
*/
export function useConfig() {
const [config, setConfig] = useState(getConfig)
useEffect(() => {
if (!config) {
loadConfig().then(setConfig)
}
}, [config])
return config
}
/**
* Hook to check a single feature flag.
* @param {string} flag - e.g. 'has_hillshade'
* @returns {boolean}
*/
export function useFeature(flag) {
const config = useConfig()
if (!config) return false
return Boolean(config.features?.[flag])
}