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();
|
const d = await resp.json();
|
||||||
if (resp.ok) {
|
if (resp.ok) {
|
||||||
setEnrichMsg(d.message ?? "Enrichment finalizat");
|
// Update detail with enrichment data directly from response
|
||||||
// Reload feature detail after enrichment
|
if (d.enrichment && detail) {
|
||||||
const objectId = feature.properties.object_id ?? feature.properties.objectId;
|
setDetail({ ...detail, enrichment: d.enrichment, enrichedAt: new Date().toISOString() });
|
||||||
if (objectId) {
|
} else {
|
||||||
const r = await fetch(`/api/geoportal/feature?objectId=${objectId}&siruta=${siruta}&sourceLayer=${feature.sourceLayer}`);
|
// 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) {
|
if (r.ok) {
|
||||||
const data = await r.json();
|
const data = await r.json();
|
||||||
setDetail(data.feature);
|
setDetail(data.feature);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
setEnrichMsg("");
|
||||||
} else {
|
} else {
|
||||||
setEnrichMsg(d.error ?? "Eroare la enrichment");
|
setEnrichMsg(d.error ?? "Eroare la enrichment");
|
||||||
}
|
}
|
||||||
@@ -161,7 +166,7 @@ export function FeatureInfoPanel({ feature, onClose }: FeatureInfoPanelProps) {
|
|||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{cfStatus?.available && cfStatus.downloadUrl && (
|
{cfStatus?.available && cfStatus.downloadUrl ? (
|
||||||
<Button
|
<Button
|
||||||
variant="outline" size="sm" className="h-7 text-xs gap-1 flex-1"
|
variant="outline" size="sm" className="h-7 text-xs gap-1 flex-1"
|
||||||
onClick={() => window.open(cfStatus.downloadUrl, "_blank")}
|
onClick={() => window.open(cfStatus.downloadUrl, "_blank")}
|
||||||
@@ -170,9 +175,7 @@ export function FeatureInfoPanel({ feature, onClose }: FeatureInfoPanelProps) {
|
|||||||
<FileDown className="h-3 w-3" />
|
<FileDown className="h-3 w-3" />
|
||||||
Descarca CF
|
Descarca CF
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
) : cadRef ? (
|
||||||
|
|
||||||
{hasEnrichment && !cfStatus?.available && (
|
|
||||||
<Button
|
<Button
|
||||||
variant="outline" size="sm" className="h-7 text-xs gap-1 flex-1"
|
variant="outline" size="sm" className="h-7 text-xs gap-1 flex-1"
|
||||||
onClick={() => window.open(`/parcel-sync?tab=extrase&search=${encodeURIComponent(cadRef)}`, "_blank")}
|
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" />
|
<Download className="h-3 w-3" />
|
||||||
Comanda CF
|
Comanda CF
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
) : null}
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
variant="outline" size="sm" className="h-7 text-xs gap-1"
|
variant="outline" size="sm" className="h-7 text-xs gap-1"
|
||||||
|
|||||||
Reference in New Issue
Block a user