diff --git a/src/modules/geoportal/v2/feature-info-panel.tsx b/src/modules/geoportal/v2/feature-info-panel.tsx index 591ece7..8b17bbb 100644 --- a/src/modules/geoportal/v2/feature-info-panel.tsx +++ b/src/modules/geoportal/v2/feature-info-panel.tsx @@ -103,8 +103,25 @@ export function FeatureInfoPanel({ feature, onClose }: Props) { }, [feature.id]); const refreshFromAncpi = async () => { - const siruta = feature.siruta || detail?.siruta || ""; + let siruta = feature.siruta || detail?.siruta || ""; const cadastralRef = feature.cadastralRef || detail?.cadastralRef || ""; + // Race fix: parcels selected from search dropdown carry id + cadref + // but no siruta. If the parcela.get auto-fetch is still in flight (or + // never fired because tile lacks uuid), hydrate siruta now. + if (!siruta && feature.id) { + try { + const res = await fetch(`/api/gis/parcela/${encodeURIComponent(feature.id)}`); + if (res.ok) { + const d = await res.json(); + if (typeof d?.siruta === "string") { + siruta = d.siruta; + setDetail(d); + } + } + } catch { + /* fall through to validation below */ + } + } if (!siruta || !cadastralRef) { setError("missing_siruta_or_cad"); return;