|
|
|
@@ -138,6 +138,28 @@ export const fetchItemsWithDetails = cache(async (searchParams?: Record<string, |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
/** Paged item lookup for Inventory Search (code / name). */ |
|
|
|
export const fetchItemsByPage = cache(async (queryParams?: Record<string, string | number>) => { |
|
|
|
const searchParams = new URLSearchParams(); |
|
|
|
if (queryParams) { |
|
|
|
Object.entries(queryParams).forEach(([key, value]) => { |
|
|
|
if (value !== undefined && value !== null && `${value}` !== "") { |
|
|
|
searchParams.set(key, String(value)); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
const queryString = searchParams.toString(); |
|
|
|
return serverFetchJson<RecordsRes<ItemsResult>>( |
|
|
|
queryString |
|
|
|
? `${BASE_API_URL}/items/getRecordByPage?${queryString}` |
|
|
|
: `${BASE_API_URL}/items/getRecordByPage`, |
|
|
|
{ |
|
|
|
method: "GET", |
|
|
|
next: { tags: ["items"] }, |
|
|
|
}, |
|
|
|
); |
|
|
|
}); |
|
|
|
|
|
|
|
export const fetchAllItemsInClient = cache(async () => { |
|
|
|
return serverFetchJson<ItemCombo[]>(`${BASE_API_URL}/items/consumables`, { |
|
|
|
next: { tags: ["items"] }, |
|
|
|
|