From 32d3f30f9d45b5088d202ed41a98d479153f3e9a Mon Sep 17 00:00:00 2001 From: AI Assistant Date: Tue, 24 Mar 2026 12:11:59 +0200 Subject: [PATCH] fix(geoportal): auto-refresh panel after enrichment + Comanda CF always visible - After enrichment: panel updates immediately with returned data (no reload needed) - "Comanda CF" button visible on any parcel with cadastral ref (not just enriched ones) - "Descarca CF" shown when CF extract already exists in DB Co-Authored-By: Claude Opus 4.6 (1M context) --- .../components/feature-info-panel.tsx | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/modules/geoportal/components/feature-info-panel.tsx b/src/modules/geoportal/components/feature-info-panel.tsx index 67c3edb..872cb99 100644 --- a/src/modules/geoportal/components/feature-info-panel.tsx +++ b/src/modules/geoportal/components/feature-info-panel.tsx @@ -77,16 +77,21 @@ export function FeatureInfoPanel({ feature, onClose }: FeatureInfoPanelProps) { }); const d = await resp.json(); if (resp.ok) { - setEnrichMsg(d.message ?? "Enrichment finalizat"); - // Reload feature detail after enrichment - const objectId = feature.properties.object_id ?? feature.properties.objectId; - if (objectId) { - const r = await fetch(`/api/geoportal/feature?objectId=${objectId}&siruta=${siruta}&sourceLayer=${feature.sourceLayer}`); - if (r.ok) { - const data = await r.json(); - setDetail(data.feature); + // Update detail with enrichment data directly from response + if (d.enrichment && detail) { + setDetail({ ...detail, enrichment: d.enrichment, enrichedAt: new Date().toISOString() }); + } else { + // Fallback: reload from API + const oid = feature.properties.object_id ?? feature.properties.objectId; + if (oid) { + const r = await fetch(`/api/geoportal/feature?objectId=${oid}&siruta=${siruta}&sourceLayer=${feature.sourceLayer}`); + if (r.ok) { + const data = await r.json(); + setDetail(data.feature); + } } } + setEnrichMsg(""); } else { setEnrichMsg(d.error ?? "Eroare la enrichment"); } @@ -161,7 +166,7 @@ export function FeatureInfoPanel({ feature, onClose }: FeatureInfoPanelProps) { )} - {cfStatus?.available && cfStatus.downloadUrl && ( + {cfStatus?.available && cfStatus.downloadUrl ? ( - )} - - {hasEnrichment && !cfStatus?.available && ( + ) : cadRef ? ( - )} + ) : null}