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) <noreply@anthropic.com>
This commit is contained in:
@@ -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}`);
|
||||
// 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) {
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{cfStatus?.available && cfStatus.downloadUrl && (
|
||||
{cfStatus?.available && cfStatus.downloadUrl ? (
|
||||
<Button
|
||||
variant="outline" size="sm" className="h-7 text-xs gap-1 flex-1"
|
||||
onClick={() => window.open(cfStatus.downloadUrl, "_blank")}
|
||||
@@ -170,9 +175,7 @@ export function FeatureInfoPanel({ feature, onClose }: FeatureInfoPanelProps) {
|
||||
<FileDown className="h-3 w-3" />
|
||||
Descarca CF
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{hasEnrichment && !cfStatus?.available && (
|
||||
) : cadRef ? (
|
||||
<Button
|
||||
variant="outline" size="sm" className="h-7 text-xs gap-1 flex-1"
|
||||
onClick={() => window.open(`/parcel-sync?tab=extrase&search=${encodeURIComponent(cadRef)}`, "_blank")}
|
||||
@@ -181,7 +184,7 @@ export function FeatureInfoPanel({ feature, onClose }: FeatureInfoPanelProps) {
|
||||
<Download className="h-3 w-3" />
|
||||
Comanda CF
|
||||
</Button>
|
||||
)}
|
||||
) : null}
|
||||
|
||||
<Button
|
||||
variant="outline" size="sm" className="h-7 text-xs gap-1"
|
||||
|
||||
Reference in New Issue
Block a user