From e6432b13f06a54ee81e098ecc4eb05ddc979e43e Mon Sep 17 00:00:00 2001 From: Claude VM Date: Tue, 19 May 2026 00:15:07 +0300 Subject: [PATCH] fix(geoportal-v2): hydrate siruta when refresh fires before parcela.get MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Audit-flagged blocker: search-dropdown feature select → setClicked with siruta:"" because gis-api /search response doesn't include siruta per feature. If user clicks "Citește din ANCPI" before the panel's auto-fetch of parcela.get completes, refresh fails with missing_siruta_or_cad. Fix: refresh handler now awaits parcela.get inline when siruta is empty + feature.id is present, then hydrates detail before posting to /api/gis/parcel/tech. Proper followup: extend gis-api /search response with siruta per feature so the race goes away entirely. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../geoportal/v2/feature-info-panel.tsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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;