From 3a2262edd03b0f6b6091ddea08ed15c68402291a Mon Sep 17 00:00:00 2001 From: AI Assistant Date: Tue, 24 Mar 2026 08:17:15 +0200 Subject: [PATCH] feat(geoportal): feature panel with Enrichment + Extras CF buttons - Parcele fara enrichment: buton "Enrichment" (sync magic de la eTerra) - Parcele cu enrichment: date complete + buton "Extras CF" (link ePay) - Buton "Copiaza" (clipboard cu NR_CAD, CF, suprafata, proprietari) - ExportFormat: removed geojson (only dxf + gpkg) - Tooltips pe fiecare buton Co-Authored-By: Claude Opus 4.6 (1M context) --- .../components/feature-info-panel.tsx | 110 ++++++++++++++++-- src/modules/geoportal/types.ts | 2 +- 2 files changed, 100 insertions(+), 12 deletions(-) diff --git a/src/modules/geoportal/components/feature-info-panel.tsx b/src/modules/geoportal/components/feature-info-panel.tsx index 9ea0266..871e91f 100644 --- a/src/modules/geoportal/components/feature-info-panel.tsx +++ b/src/modules/geoportal/components/feature-info-panel.tsx @@ -1,7 +1,7 @@ "use client"; import { useEffect, useState } from "react"; -import { X, Loader2 } from "lucide-react"; +import { X, Loader2, Sparkles, FileText, Download } from "lucide-react"; import { Button } from "@/shared/components/ui/button"; import type { ClickedFeature, FeatureDetail, FeatureEnrichmentData } from "../types"; @@ -13,6 +13,8 @@ type FeatureInfoPanelProps = { export function FeatureInfoPanel({ feature, onClose }: FeatureInfoPanelProps) { const [detail, setDetail] = useState(null); const [loading, setLoading] = useState(false); + const [enriching, setEnriching] = useState(false); + const [enrichMsg, setEnrichMsg] = useState(""); useEffect(() => { if (!feature) { setDetail(null); return; } @@ -23,6 +25,7 @@ export function FeatureInfoPanel({ feature, onClose }: FeatureInfoPanelProps) { let cancelled = false; setLoading(true); + setEnrichMsg(""); fetch(`/api/geoportal/feature?objectId=${objectId}&siruta=${siruta}&sourceLayer=${feature.sourceLayer}`) .then((r) => r.ok ? r.json() : Promise.reject()) @@ -37,10 +40,36 @@ export function FeatureInfoPanel({ feature, onClose }: FeatureInfoPanelProps) { const e = detail?.enrichment as FeatureEnrichmentData | null | undefined; const isUat = feature.sourceLayer?.includes("uat"); - const cadRef = e?.NR_CAD ?? feature.properties.cadastral_ref ?? ""; + const cadRef = e?.NR_CAD ?? String(feature.properties.cadastral_ref ?? ""); const title = isUat ? String(feature.properties.name ?? "UAT") : cadRef ? `Parcela ${cadRef}` : `#${feature.properties.object_id ?? "?"}`; + const hasEnrichment = !!e && !!e.NR_CAD; + const nrCf = e?.NR_CF ?? ""; + + const handleEnrich = async () => { + if (!detail?.siruta || !detail?.objectId) return; + setEnriching(true); + setEnrichMsg(""); + try { + // Trigger enrichment for this specific parcel's UAT + const resp = await fetch("/api/eterra/enrich", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ siruta: detail.siruta, featureId: detail.id }), + }); + if (resp.ok) { + setEnrichMsg("Enrichment pornit. Reincarca pagina dupa cateva secunde."); + } else { + const d = await resp.json().catch(() => null); + setEnrichMsg((d && typeof d === "object" && "error" in d) ? String((d as { error: string }).error) : "Eroare la enrichment"); + } + } catch { + setEnrichMsg("Eroare retea"); + } finally { + setEnriching(false); + } + }; return (
@@ -70,19 +99,78 @@ export function FeatureInfoPanel({ feature, onClose }: FeatureInfoPanelProps) { {!loading && !isUat && ( <> - - + - {e?.PROPRIETARI && e.PROPRIETARI !== "-" && ( - + + {hasEnrichment && ( + <> + {e?.PROPRIETARI && e.PROPRIETARI !== "-" && ( + + )} + {e?.INTRAVILAN && e.INTRAVILAN !== "-" && ( + + )} + {e?.CATEGORIE_FOLOSINTA && e.CATEGORIE_FOLOSINTA !== "-" && ( + + )} + )} - {e?.INTRAVILAN && e.INTRAVILAN !== "-" && ( - - )} - {e?.CATEGORIE_FOLOSINTA && e.CATEGORIE_FOLOSINTA !== "-" && ( - + + {/* Action buttons */} +
+ {!hasEnrichment && ( + + )} + + {hasEnrichment && nrCf && ( + + )} + + +
+ + {enrichMsg && ( +

{enrichMsg}

)} )} diff --git a/src/modules/geoportal/types.ts b/src/modules/geoportal/types.ts index f8ce8bf..bb3ad44 100644 --- a/src/modules/geoportal/types.ts +++ b/src/modules/geoportal/types.ts @@ -117,4 +117,4 @@ export type FeatureEnrichmentData = { /* Export */ /* ------------------------------------------------------------------ */ -export type ExportFormat = "dxf" | "gpkg" | "geojson"; +export type ExportFormat = "dxf" | "gpkg";