Skip to content

Commit

Permalink
Merge pull request #53 from Bahmni-HWC/GOK-396
Browse files Browse the repository at this point in the history
GOK-396 | Fix. Only 50 patients displayed in inventory dashboard
  • Loading branch information
riyaTw authored Oct 13, 2023
2 parents 8938d66 + 7172448 commit c1f6257
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/inventory/inventory-menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const InventoryMenu = () => {
const { setStockRoom, setStockRoomError } = useStockRoomContext();
const { itemStock ,itemStockError} = useItemStockContext();
const [reloadData, setReloadData] = React.useState(false);
const totalInventoryItemsInStockroom = React.useRef(null);
const [totalInventoryItemsInStockroom, setTotalInventoryItemsInStockroom] = React.useState(null);

const { data: stockRoom, error: stockRoomError } = useSWR(
cookies[locationCookieName]?.name.trim() ? stockRoomURL(cookies[locationCookieName]?.name.trim()) : null,
Expand All @@ -36,18 +36,18 @@ const InventoryMenu = () => {
const fetchInventoryItems = async () => {
try {
if (stockRoom) {
const response = await getRequest(invItemURLByStockroom(stockRoom.results[0].uuid, totalInventoryItemsInStockroom.current));
const response = await getRequest(invItemURLByStockroom(stockRoom.results[0].uuid, totalInventoryItemsInStockroom));
setItemStock(response.results);
if (response.length !== totalInventoryItemsInStockroom.current) {
totalInventoryItemsInStockroom.current = response.length;
if (response.length !== totalInventoryItemsInStockroom) {
setTotalInventoryItemsInStockroom(response.length);
}
}
} catch (error) {
setItemStockError(error);
}
};
fetchInventoryItems();
}, [reloadData,stockRoom,totalInventoryItemsInStockroom.current]);
}, [reloadData,stockRoom,totalInventoryItemsInStockroom]);

if ((itemStock === undefined && itemStockError === undefined) || (!stockRoom && !stockRoomError))
return <Loading />;
Expand Down

0 comments on commit c1f6257

Please sign in to comment.