diff --git a/src/pages/travel/AlbumDetail.jsx b/src/pages/travel/AlbumDetail.jsx index 3d70e7a..cbe3a39 100644 --- a/src/pages/travel/AlbumDetail.jsx +++ b/src/pages/travel/AlbumDetail.jsx @@ -189,6 +189,31 @@ export default function AlbumDetail({ /* ── Derived ── */ const regionAccent = getRegionAccent(album?.region || album?.id || ''); + + // Determine if the album's region is a custom region missing coordinates + const currentRegionId = savedRegionId || album?.region || album?.id || ''; + const needsPin = useMemo(() => { + if (!currentRegionId || !regions?.features) return false; + const feature = regions.features.find((f) => { + const rid = f.properties?.id || f.properties?.name || ''; + return rid.toLowerCase() === currentRegionId.toLowerCase(); + }); + if (!feature) return true; // region not in GeoJSON at all → needs pin + if (feature.properties?.custom && !feature.geometry) return true; // custom without coords + return false; + }, [currentRegionId, regions]); + + // Coords of existing pin (for initialCoords in picker) + const existingCoords = useMemo(() => { + if (!currentRegionId || !regions?.features) return null; + const feature = regions.features.find((f) => { + const rid = f.properties?.id || f.properties?.name || ''; + return rid.toLowerCase() === currentRegionId.toLowerCase(); + }); + if (feature?.geometry?.type === 'Point') return feature.geometry.coordinates; + return null; + }, [currentRegionId, regions]); + const photoCountLabel = photoSummary?.total ? `${photoSummary.total} photos` : photos?.length @@ -323,7 +348,7 @@ export default function AlbumDetail({ - {regionMsg?.type === 'ok' && savedRegionId && ( + {(needsPin || (regionMsg?.type === 'ok' && savedRegionId)) && (