fix(ancpi): test SearchEstate with various uatId values
This commit is contained in:
@@ -80,38 +80,27 @@ export async function GET(req: Request) {
|
|||||||
if (step === "search") {
|
if (step === "search") {
|
||||||
const client = await EpayClient.create(username, password);
|
const client = await EpayClient.create(username, password);
|
||||||
const countyIdx = resolveEpayCountyIndex("Cluj")!;
|
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> = {};
|
const results: Record<string, unknown> = {};
|
||||||
|
|
||||||
if (clujNapoca) {
|
// Test 1: uatId=-1 (maybe "all")
|
||||||
results["345295_ClujNapoca"] = await client.searchEstate(
|
results["345295_uatNeg1"] = await client.searchEstate("345295", countyIdx, -1).catch((e: Error) => ({ error: e.message }));
|
||||||
"345295", countyIdx, clujNapoca.id
|
|
||||||
);
|
// Test 2: uatId=0
|
||||||
}
|
results["345295_uat0"] = await client.searchEstate("345295", countyIdx, 0).catch((e: Error) => ({ error: e.message }));
|
||||||
if (feleacu) {
|
|
||||||
results["63565_Feleacu"] = await client.searchEstate(
|
// Test 3: uatId=24 (from spec: Cluj-Napoca is index 24)
|
||||||
"63565", countyIdx, feleacu.id
|
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
|
||||||
if (floresti) {
|
// For now just try a few indices for Feleacu/Florești
|
||||||
results["88089_Floresti"] = await client.searchEstate(
|
results["63565_uat0"] = await client.searchEstate("63565", countyIdx, 0).catch((e: Error) => ({ error: e.message }));
|
||||||
"88089", countyIdx, floresti.id
|
results["88089_uat0"] = await client.searchEstate("88089", countyIdx, 0).catch((e: Error) => ({ error: e.message }));
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
step: "search",
|
step: "search",
|
||||||
uats: { clujNapoca, feleacu, floresti },
|
countyIdx,
|
||||||
results,
|
results,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user