diff --git a/src/app/api/gis/parcela/[id]/route.ts b/src/app/api/gis/parcela/[id]/route.ts index 055e0d5..2f0d487 100644 --- a/src/app/api/gis/parcela/[id]/route.ts +++ b/src/app/api/gis/parcela/[id]/route.ts @@ -20,9 +20,19 @@ export async function GET( } try { - return NextResponse.json(await gisApi.parcela.get(id)); + const data = await gisApi.parcela.get(id); + const enr = + (data as { enrichment?: Record } | null)?.enrichment ?? null; + console.log( + "[gis-parcela] id=%s has_enrich=%s keys=%d", + id.slice(0, 8), + !!enr, + enr ? Object.keys(enr).length : 0, + ); + return NextResponse.json(data); } catch (err) { if (err instanceof GisApiError) { + console.log("[gis-parcela] gis-api %d %s", err.status, err.code); return NextResponse.json( { error: err.code, status: err.status }, { status: err.status }, diff --git a/src/modules/geoportal/v2/feature-info-panel.tsx b/src/modules/geoportal/v2/feature-info-panel.tsx index fed516c..cb0ccf1 100644 --- a/src/modules/geoportal/v2/feature-info-panel.tsx +++ b/src/modules/geoportal/v2/feature-info-panel.tsx @@ -61,8 +61,6 @@ export function FeatureInfoPanel({ feature, onClose }: Props) { const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const [refreshing, setRefreshing] = useState(false); - const [ordering, setOrdering] = useState(false); - const [orderResult, setOrderResult] = useState(null); // Fetch detail when feature changes. // If tile carries the GisFeature uuid: use the fast path (parcela.get, @@ -179,38 +177,15 @@ export function FeatureInfoPanel({ feature, onClose }: Props) { window.open(url, "_blank", "noopener,noreferrer"); }; - const orderCf = async () => { - if (!feature.cadastralRef) { - setOrderResult("Lipsește nr. cadastral"); - return; - } - setOrdering(true); - setOrderResult(null); - try { - const res = await fetch("/api/cf/order", { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ - nrCadastral: feature.cadastralRef, - siruta: feature.siruta || detail?.siruta || undefined, - gisFeatureId: feature.id || undefined, - }), - }); - const body = await res.json().catch(() => ({})); - if (res.status === 409 && body?.error === "catalog_hit") { - setOrderResult("Extras CF valid deja există"); - return; - } - if (!res.ok) { - setOrderResult(body?.error || `Eroare comandă (HTTP ${res.status})`); - return; - } - setOrderResult("Comandat — se procesează în background"); - } catch { - setOrderResult("Eroare rețea"); - } finally { - setOrdering(false); - } + const orderCf = () => { + // The map-side panel doesn't have judet / uat / credit context that the + // ePay flow needs to render properly. Redirect to the parcel-sync page + // (eTerra Parcele → ePay tab) where the user has the full UI: own ePay + // session, visible credit balance, decrement per order. Filter by the + // cadastral so the user lands on this parcel. + const cad = encodeURIComponent(feature.cadastralRef); + const url = `/parcel-sync?tab=epay&cad=${cad}`; + window.open(url, "_blank", "noopener,noreferrer"); }; const enrichment = (detail?.enrichment ?? {}) as Record; @@ -349,25 +324,12 @@ export function FeatureInfoPanel({ feature, onClose }: Props) { - {orderResult && ( -
- {orderResult} -
- )} );