Clean up API client - use nested propertyInformation directly
All checks were successful
Build frontend / build (push) Successful in 42s

- Removed manual enrichment calls (Properties/Get fallback no longer needed)
- Removed unused hasNestedInfo variables
- API now returns propertyInformation nested in RentProperties/SaleProperties
This commit is contained in:
Claw AI
2026-03-26 23:27:28 +00:00
parent fd3dcf4cc3
commit 211ac42ad9
4 changed files with 9 additions and 62 deletions

View File

@ -37,39 +37,13 @@ async function apiFetch(endpoint, options = {}) {
// ─── Rent Properties ───
export async function getRentProperties() {
const rentList = await apiFetch('/RentProperties/GetRentProperties');
if (!Array.isArray(rentList) || rentList.length === 0) return rentList;
// Fetch property info for each rent property's propInfoId
const enriched = await Promise.all(
rentList.map(async (item) => {
try {
const propInfo = await apiFetch(`/Properties/Get/${item.propInfoId}`);
return { ...item, propertyInformation: propInfo };
} catch {
return item;
}
})
);
return enriched;
return apiFetch('/RentProperties/GetRentProperties');
}
export async function getRentProperty(id) {
const item = await apiFetch(`/RentProperties/GetRentProperties?id=${id}`);
if (!item) return item;
// If it's an array (all results), pick the matching one
const property = Array.isArray(item) ? item.find(p => p.id == id) || item[0] : item;
if (property?.propInfoId) {
try {
const propInfo = await apiFetch(`/Properties/Get/${property.propInfoId}`);
return { ...property, propertyInformation: propInfo };
} catch {
// ignore
}
}
return property;
const items = await apiFetch('/RentProperties/GetRentProperties');
if (!Array.isArray(items)) return items;
return items.find(p => p.id == id) || items[0];
}
export async function getRentPropertyLocations(params = {}) {
@ -83,35 +57,13 @@ export async function getRentPropertyLocations(params = {}) {
// ─── Sale Properties ───
export async function getSaleProperties() {
const saleList = await apiFetch('/SaleProperties/GetSaleProperties');
if (!Array.isArray(saleList) || saleList.length === 0) return saleList;
const enriched = await Promise.all(
saleList.map(async (item) => {
try {
const propInfo = await apiFetch(`/Properties/Get/${item.propInfoId}`);
return { ...item, propertyInformation: propInfo };
} catch {
return item;
}
})
);
return enriched;
return apiFetch('/SaleProperties/GetSaleProperties');
}
export async function getSaleProperty(id) {
const item = await apiFetch(`/SaleProperties/GetSaleProperties?id=${id}`);
const property = Array.isArray(item) ? item.find(p => p.id == id) || item[0] : item;
if (property?.propInfoId) {
try {
const propInfo = await apiFetch(`/Properties/Get/${property.propInfoId}`);
return { ...property, propertyInformation: propInfo };
} catch {
// ignore
}
}
return property;
const items = await apiFetch('/SaleProperties/GetSaleProperties');
if (!Array.isArray(items)) return items;
return items.find(p => p.id == id) || items[0];
}
// ─── Properties (generic) ───