diff --git a/src/app/api/settings/item/actions.ts b/src/app/api/settings/item/actions.ts index f6b91807..2b241dee 100644 --- a/src/app/api/settings/item/actions.ts +++ b/src/app/api/settings/item/actions.ts @@ -138,6 +138,28 @@ export const fetchItemsWithDetails = cache(async (searchParams?: Record) => { + 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>( + queryString + ? `${BASE_API_URL}/items/getRecordByPage?${queryString}` + : `${BASE_API_URL}/items/getRecordByPage`, + { + method: "GET", + next: { tags: ["items"] }, + }, + ); +}); + export const fetchAllItemsInClient = cache(async () => { return serverFetchJson(`${BASE_API_URL}/items/consumables`, { next: { tags: ["items"] },