fix(geoportal-v2): hydrate siruta when refresh fires before parcela.get

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) <noreply@anthropic.com>
This commit is contained in:
Claude VM
2026-05-19 00:15:07 +03:00
parent 21a058b429
commit e6432b13f0
@@ -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;