feat(parcel-sync): show county in UAT search dropdown via eTerra data

PATCH /api/eterra/uats fetches counties from eTerra nomenclature and
LIMITE_UAT layer, then batch-updates GisUat records with county name
and workspacePk. Auto-triggers on first eTerra connection when county
data is missing. Helps distinguish same-name UATs in different counties.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
AI Assistant
2026-03-22 20:46:13 +02:00
parent 2a25e4b160
commit 86c39473a5
3 changed files with 214 additions and 2 deletions
@@ -553,10 +553,38 @@ export function ParcelSyncModule() {
}, [fetchDbSummary]);
/* ════════════════════════════════════════════════════════════ */
/* (Sync effect removed — POST seeds from uat.json, no */
/* eTerra nomenclature needed. Workspace resolved lazily.) */
/* Auto-refresh county data when eTerra is connected */
/* ════════════════════════════════════════════════════════════ */
const countyRefreshAttempted = useRef(false);
useEffect(() => {
if (!session.connected || countyRefreshAttempted.current) return;
if (uatData.length === 0) return;
// Check if most UATs are missing county data
const withCounty = uatData.filter((u) => u.county).length;
if (withCounty > uatData.length * 0.5) return; // >50% already have county
countyRefreshAttempted.current = true;
console.log("[uats] Auto-refreshing county data from eTerra…");
fetch("/api/eterra/uats", { method: "PATCH" })
.then((res) => res.json())
.then((result: { updated?: number; error?: string }) => {
if (result.updated && result.updated > 0) {
// Reload UAT data with fresh county info
fetch("/api/eterra/uats")
.then((res) => res.json())
.then((data: { uats?: UatEntry[] }) => {
if (data.uats && data.uats.length > 0) setUatData(data.uats);
})
.catch(() => {});
}
})
.catch(() => {});
}, [session.connected, uatData]);
/* ════════════════════════════════════════════════════════════ */
/* UAT autocomplete filter */
/* ════════════════════════════════════════════════════════════ */