Update inventoryService.ts
This commit is contained in:
parent
23f8818257
commit
c69625e43d
@ -380,7 +380,13 @@ export const addItem = async (
|
||||
}
|
||||
};
|
||||
} else {
|
||||
inventory.LevelKeys.push({ ItemType: typeName, ItemCount: quantity });
|
||||
const itemIndex = inventory.LevelKeys.findIndex(i => i.ItemType === typeName);
|
||||
|
||||
if (itemIndex !== -1) {
|
||||
inventory.LevelKeys[itemIndex].ItemCount += quantity;
|
||||
} else {
|
||||
inventory.LevelKeys.push({ ItemType: typeName, ItemCount: quantity });
|
||||
}
|
||||
return {
|
||||
InventoryChanges: {
|
||||
LevelKeys: [
|
||||
|
Loading…
x
Reference in New Issue
Block a user