Selaa lähdekoodia

inventory search update

production
CANCERYS\kw093 8 tuntia sitten
vanhempi
commit
245b86e463
2 muutettua tiedostoa jossa 19 lisäystä ja 3 poistoa
  1. +16
    -0
      src/app/api/inventory/actions.ts
  2. +3
    -3
      src/components/InventorySearch/InventorySearch.tsx

+ 16
- 0
src/app/api/inventory/actions.ts Näytä tiedosto

@@ -160,13 +160,29 @@ async function fetchInventoriesImpl(data: SearchInventory) {
);
}

async function fetchInventoriesLatestImpl(data: SearchInventory) {
const queryStr = convertObjToURLSearchParams(data);
return serverFetchJson<InventoryResultByPage>(
`${BASE_API_URL}/inventory/searchLatest/getRecordByPage?${queryStr}`,
{ next: { tags: ["inventories"] } },
);
}

export const fetchInventories = cache(fetchInventoriesImpl);

/** Inventory search page: latest inventory row per item (no baseUnit/uomId filter). */
export const fetchInventoriesLatest = cache(fetchInventoriesLatestImpl);

/** Bypass React cache() after mutations so lists show fresh qty. */
export async function fetchInventoriesFresh(data: SearchInventory) {
return fetchInventoriesImpl(data);
}

/** Bypass React cache() for inventory search page latest-inventory search. */
export async function fetchInventoriesLatestFresh(data: SearchInventory) {
return fetchInventoriesLatestImpl(data);
}

async function fetchInventoryLotLinesImpl(data: SearchInventoryLotLine) {
const queryStr = convertObjToURLSearchParams(data);
return serverFetchJson<InventoryLotLineResultByPage>(


+ 3
- 3
src/components/InventorySearch/InventorySearch.tsx Näytä tiedosto

@@ -12,7 +12,7 @@ import {
analyzeQrCode,
SearchInventory,
SearchInventoryLotLine,
fetchInventories,
fetchInventoriesLatest,
fetchInventoryLotLines,
} from '@/app/api/inventory/actions';
import { PrinterCombo } from '@/app/api/settings/printer';
@@ -187,7 +187,7 @@ const InventorySearch: React.FC<Props> = ({ inventories, printerCombo }) => {
pageSize: pagingController.pageSize,
};

const response = await fetchInventories(params);
const response = await fetchInventoriesLatest(params);

if (response) {
setInventoriesTotalCount(response.total);
@@ -199,7 +199,7 @@ const InventorySearch: React.FC<Props> = ({ inventories, printerCombo }) => {
break;
case 'paging':
setFilteredInventories((fi) =>
uniqBy([...fi, ...response.records], 'id'),
uniqBy([...fi, ...response.records], 'itemId'),
);
}
}


Ladataan…
Peruuta
Tallenna