fix(ancpi): test SearchEstate with various uatId values

This commit is contained in:
AI Assistant
2026-03-23 01:18:58 +02:00
parent 0447908007
commit f92fcfd86b
+15 -26
View File
@@ -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<string, unknown> = {};
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,
});
}