diff --git a/src/modules/geoportal/v2/feature-info-panel.tsx b/src/modules/geoportal/v2/feature-info-panel.tsx index cdc0a28..efc0470 100644 --- a/src/modules/geoportal/v2/feature-info-panel.tsx +++ b/src/modules/geoportal/v2/feature-info-panel.tsx @@ -576,8 +576,22 @@ export function FeatureInfoPanel({ feature, onClose, onSelectFeature, basic = fa }, [buildings]); // ── Condo owners for buildings ────────────────────────── + // Only fires for buildings flagged IS_CONDOMINIUM=1 (or + // PARCEL_IS_CONDOMINIUM=1). For everything else the orchestrator's + // eTerra round-trip would take ~10s and come back empty — bad UX. + // We wait for `detail` to land so we can read the flag from enrichment. useEffect(() => { if (basic || !isCladiri || !feature.siruta || !feature.cadastralRef) return; + if (!detail) return; + const e = (detail.enrichment ?? {}) as Record; + const isCondo = + Number(e.IS_CONDOMINIUM ?? 0) === 1 || + Number(e.PARCEL_IS_CONDOMINIUM ?? 0) === 1; + if (!isCondo) { + setCondoOwners(null); + setCondoLoading(false); + return; + } let cancelled = false; setCondoOwners(null); setCondoLoading(true); @@ -593,6 +607,9 @@ export function FeatureInfoPanel({ feature, onClose, onSelectFeature, basic = fa }); if (cancelled) return; if (!r.ok) { + // Treat any failure as "no apartments known" — keep section + // visible with a note instead of hiding silently. + setCondoOwners([]); setCondoLoading(false); return; } @@ -608,14 +625,17 @@ export function FeatureInfoPanel({ feature, onClose, onSelectFeature, basic = fa setCondoLoading(false); } } catch { - if (!cancelled) setCondoLoading(false); + if (!cancelled) { + setCondoOwners([]); + setCondoLoading(false); + } } }; void run(); return () => { cancelled = true; }; - }, [isCladiri, feature.siruta, feature.cadastralRef, basic]); + }, [isCladiri, feature.siruta, feature.cadastralRef, basic, detail]); // ── Manual + auto refresh (deep enrich) ───────────────── const refreshFromAncpi = useCallback( @@ -1164,8 +1184,11 @@ export function FeatureInfoPanel({ feature, onClose, onSelectFeature, basic = fa )} - {/* Apartamente (cladiri only) */} - {!loading && isCladiri && (condoLoading || (condoOwners && condoOwners.length > 0)) && ( + {/* Apartamente (cladiri only — only mounted when IS_CONDOMINIUM=1 + per the gating useEffect; non-condos skip the fetch entirely + so we never sit on a 10s eTerra round-trip just to discover + there's nothing to show). */} + {!loading && isCladiri && (condoLoading || condoOwners != null) && (

@@ -1181,6 +1204,11 @@ export function FeatureInfoPanel({ feature, onClose, onSelectFeature, basic = fa se încarcă…

)} + {!condoLoading && condoOwners != null && condoOwners.length === 0 && ( +

+ Fără apartamente înregistrate la ANCPI. +

+ )} {condoOwners && condoOwners.length > 0 && (
{condoOwners.map((u, i) => (