77da69e29f
User pushback on the pool-based CF flow: he wants his own ePay account (per-user creds, visible credit balance, decrement per order) — not the shared orchestrator pool which hides cost attribution. V2 panel "Comandă CF" now opens /parcel-sync?tab=epay&cad=<ref> in a new tab where the legacy UI handles ordering with credits. The /api/cf/* gis-api routes stay (used elsewhere + future SaaS consumers) but the V2 button doesn't hit them. Plus diagnostic on /api/gis/parcela showing enrichment presence + key count to debug "data nu raman" — should reveal whether Marius's session is getting full enrichment back from gis-api. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
49 lines
1.4 KiB
TypeScript
49 lines
1.4 KiB
TypeScript
import { NextResponse } from "next/server";
|
|
import { getAuthSession } from "@/core/auth/require-auth";
|
|
import { gisApi, GisApiError } from "@/lib/gis-api-client";
|
|
|
|
export const runtime = "nodejs";
|
|
export const dynamic = "force-dynamic";
|
|
|
|
export async function GET(
|
|
_request: Request,
|
|
{ params }: { params: Promise<{ id: string }> },
|
|
) {
|
|
const session = await getAuthSession();
|
|
if (!session) {
|
|
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
|
}
|
|
|
|
const { id } = await params;
|
|
if (!id) {
|
|
return NextResponse.json({ error: "missing_id" }, { status: 400 });
|
|
}
|
|
|
|
try {
|
|
const data = await gisApi.parcela.get(id);
|
|
const enr =
|
|
(data as { enrichment?: Record<string, unknown> } | 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 },
|
|
);
|
|
}
|
|
const msg = err instanceof Error ? err.message : String(err);
|
|
console.error("[gis-parcela] internal error:", msg);
|
|
return NextResponse.json(
|
|
{ error: "internal_error", hint: msg.slice(0, 200) },
|
|
{ status: 500 },
|
|
);
|
|
}
|
|
}
|