diff --git a/src/modules/geoportal/components/feature-info-panel.tsx b/src/modules/geoportal/components/feature-info-panel.tsx index 872cb99..a60e157 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, Sparkles, FileDown, Download, ClipboardCopy } from "lucide-react"; +import { X, Loader2, Sparkles, FileDown, Download, ClipboardCopy, Building2, AlertTriangle } from "lucide-react"; import { Button } from "@/shared/components/ui/button"; import type { ClickedFeature, FeatureDetail, FeatureEnrichmentData } from "../types"; @@ -19,10 +19,8 @@ export function FeatureInfoPanel({ feature, onClose }: FeatureInfoPanelProps) { const [enrichMsg, setEnrichMsg] = useState(""); const [cfStatus, setCfStatus] = useState(null); - // Fetch feature detail useEffect(() => { if (!feature) { setDetail(null); setCfStatus(null); return; } - const objectId = feature.properties.object_id ?? feature.properties.objectId; const siruta = feature.properties.siruta; if (!objectId || !siruta) { setDetail(null); return; } @@ -37,7 +35,6 @@ export function FeatureInfoPanel({ feature, onClose }: FeatureInfoPanelProps) { .then((data: { feature: FeatureDetail }) => { if (cancelled) return; setDetail(data.feature); - // Check CF status if we have a cadastral ref const e = data.feature.enrichment as FeatureEnrichmentData | null; const nrCad = e?.NR_CAD ?? data.feature.cadastralRef; if (nrCad) { @@ -61,7 +58,9 @@ export function FeatureInfoPanel({ feature, onClose }: FeatureInfoPanelProps) { const title = isUat ? String(feature.properties.name ?? "UAT") : cadRef ? `Parcela ${cadRef}` : `#${feature.properties.object_id ?? "?"}`; - const hasEnrichment = !!e && !!e.NR_CAD; + + // Has ANY enrichment data (not just NR_CAD) + const hasEnrichment = !!e && Object.values(e).some((v) => v != null && v !== "" && v !== "-" && v !== 0); const siruta = String(feature.properties.siruta ?? detail?.siruta ?? ""); const handleEnrich = async () => { @@ -77,21 +76,16 @@ export function FeatureInfoPanel({ feature, onClose }: FeatureInfoPanelProps) { }); const d = await resp.json(); if (resp.ok) { - // Update detail with enrichment data directly from response if (d.enrichment && detail) { setDetail({ ...detail, enrichment: d.enrichment, enrichedAt: new Date().toISOString() }); + setEnrichMsg(""); } else { - // Fallback: reload from API + // 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); - } - } + 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(""); } - setEnrichMsg(""); } else { setEnrichMsg(d.error ?? "Eroare la enrichment"); } @@ -102,28 +96,17 @@ export function FeatureInfoPanel({ feature, onClose }: FeatureInfoPanelProps) { } }; - const handleCopy = () => { - const text = [ - cadRef && `Nr. cad: ${cadRef}`, - e?.NR_CF && `CF: ${e.NR_CF}`, - (e?.SUPRAFATA_2D ?? feature.properties.area_value) && `S: ${e?.SUPRAFATA_2D ?? feature.properties.area_value} mp`, - e?.PROPRIETARI && e.PROPRIETARI !== "-" && `Prop: ${e.PROPRIETARI}`, - siruta && `SIRUTA: ${siruta}`, - ].filter(Boolean).join("\n"); - navigator.clipboard.writeText(text); - }; - return ( -
+
{/* Header */} -
+

{title}

-
+
{loading && (
Se incarca... @@ -140,16 +123,39 @@ export function FeatureInfoPanel({ feature, onClose }: FeatureInfoPanelProps) { {!loading && !isUat && ( <> + {/* Basic info */} + + + {/* Enrichment data */} {hasEnrichment && ( <> - {e?.PROPRIETARI && e.PROPRIETARI !== "-" && } - {e?.INTRAVILAN && e.INTRAVILAN !== "-" && } - {e?.CATEGORIE_FOLOSINTA && e.CATEGORIE_FOLOSINTA !== "-" && } +
+ + + + + + + + {/* Building info */} + {(e?.HAS_BUILDING === 1) && ( +
+ + Constructie: + + {e?.BUILD_LEGAL === 1 ? "Cu acte" : ( + + Fara acte + + )} + +
+ )} )} @@ -159,10 +165,10 @@ export function FeatureInfoPanel({ feature, onClose }: FeatureInfoPanelProps) { )} @@ -188,14 +194,24 @@ export function FeatureInfoPanel({ feature, onClose }: FeatureInfoPanelProps) {
{enrichMsg && ( -

{enrichMsg}

+

{enrichMsg}

)} )} @@ -204,12 +220,24 @@ export function FeatureInfoPanel({ feature, onClose }: FeatureInfoPanelProps) { ); } +/** Single-line row (value truncated only if very long) */ function Row({ label, value }: { label: string; value: unknown }) { - if (!value || value === "-" || value === "") return null; + if (!value || value === "-" || value === "" || value === 0) return null; return (
{label} - {String(value)} + {String(value)} +
+ ); +} + +/** Multi-line row (long text wraps) */ +function WrapRow({ label, value }: { label: string; value: unknown }) { + if (!value || value === "-" || value === "") return null; + return ( +
+ {label} +

{String(value)}

); } diff --git a/src/modules/geoportal/components/layer-panel.tsx b/src/modules/geoportal/components/layer-panel.tsx index 59b3bc5..ee42277 100644 --- a/src/modules/geoportal/components/layer-panel.tsx +++ b/src/modules/geoportal/components/layer-panel.tsx @@ -26,14 +26,14 @@ const LAYER_GROUPS: LayerGroupDef[] = [ label: "Terenuri", description: "Parcele cadastrale (zoom >= 13)", color: "#22c55e", - defaultVisible: true, + defaultVisible: false, }, { id: "cladiri", label: "Cladiri", description: "Constructii (zoom >= 14)", color: "#3b82f6", - defaultVisible: true, + defaultVisible: false, }, { id: "uats",