From f92fcfd86bf02b97b3ce74b431d60ac88d5dd9c1 Mon Sep 17 00:00:00 2001 From: AI Assistant Date: Mon, 23 Mar 2026 01:18:58 +0200 Subject: [PATCH] fix(ancpi): test SearchEstate with various uatId values --- src/app/api/ancpi/test/route.ts | 41 ++++++++++++--------------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/src/app/api/ancpi/test/route.ts b/src/app/api/ancpi/test/route.ts index efaeb2a..1bf492f 100644 --- a/src/app/api/ancpi/test/route.ts +++ b/src/app/api/ancpi/test/route.ts @@ -80,38 +80,27 @@ export async function GET(req: Request) { if (step === "search") { const client = await EpayClient.create(username, password); const countyIdx = resolveEpayCountyIndex("Cluj")!; - const uatList = await client.getUatList(countyIdx); - const normalize = (s: string) => - s.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toUpperCase(); - - const findUat = (name: string) => - uatList.find((u) => normalize(u.value).includes(name)); - - const clujNapoca = findUat("CLUJ-NAPOCA") ?? findUat("CLUJNAPOCA"); - const feleacu = findUat("FELEACU"); - const floresti = findUat("FLORESTI"); + // Try SearchEstate with different uatId values to find what works const results: Record = {}; - if (clujNapoca) { - results["345295_ClujNapoca"] = await client.searchEstate( - "345295", countyIdx, clujNapoca.id - ); - } - if (feleacu) { - results["63565_Feleacu"] = await client.searchEstate( - "63565", countyIdx, feleacu.id - ); - } - if (floresti) { - results["88089_Floresti"] = await client.searchEstate( - "88089", countyIdx, floresti.id - ); - } + // Test 1: uatId=-1 (maybe "all") + results["345295_uatNeg1"] = await client.searchEstate("345295", countyIdx, -1).catch((e: Error) => ({ error: e.message })); + + // Test 2: uatId=0 + results["345295_uat0"] = await client.searchEstate("345295", countyIdx, 0).catch((e: Error) => ({ error: e.message })); + + // Test 3: uatId=24 (from spec: Cluj-Napoca is index 24) + results["345295_uat24"] = await client.searchEstate("345295", countyIdx, 24).catch((e: Error) => ({ error: e.message })); + + // Test 4: no uatId at all — modify searchEstate to support optional + // For now just try a few indices for Feleacu/Florești + results["63565_uat0"] = await client.searchEstate("63565", countyIdx, 0).catch((e: Error) => ({ error: e.message })); + results["88089_uat0"] = await client.searchEstate("88089", countyIdx, 0).catch((e: Error) => ({ error: e.message })); return NextResponse.json({ step: "search", - uats: { clujNapoca, feleacu, floresti }, + countyIdx, results, }); }