From f7f57e1f55576a98c390093985872a01d183d9ec Mon Sep 17 00:00:00 2001 From: MyNameIsBatman Date: Fri, 30 Sep 2022 00:29:31 -0300 Subject: [PATCH] Fix crafting --- .../room/widgets/furniture/FurnitureCraftingView.tsx | 3 ++- .../rooms/widgets/furniture/useFurnitureCraftingWidget.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/room/widgets/furniture/FurnitureCraftingView.tsx b/src/components/room/widgets/furniture/FurnitureCraftingView.tsx index 28324392..88cf5a27 100644 --- a/src/components/room/widgets/furniture/FurnitureCraftingView.tsx +++ b/src/components/room/widgets/furniture/FurnitureCraftingView.tsx @@ -24,7 +24,8 @@ export const FurnitureCraftingView: FC<{}> = props => { const ingredientData = ingredients.find(data => (data.name === ingredient.itemName)); - if (ingredientData.count < ingredient.count) return false; + + if (!ingredientData || ingredientData.count < ingredient.count) return false; } return true; diff --git a/src/hooks/rooms/widgets/furniture/useFurnitureCraftingWidget.ts b/src/hooks/rooms/widgets/furniture/useFurnitureCraftingWidget.ts index 8399a8e9..8157172f 100644 --- a/src/hooks/rooms/widgets/furniture/useFurnitureCraftingWidget.ts +++ b/src/hooks/rooms/widgets/furniture/useFurnitureCraftingWidget.ts @@ -122,7 +122,7 @@ const useFurnitureCraftingWidgetState = () => useEffect(() => { - if(!groupItems || !groupItems.length || !ingredientNames || !ingredientNames.length) return; + if(!ingredientNames || !ingredientNames.length) return; setIngredients(prevValue => { @@ -138,7 +138,7 @@ const useFurnitureCraftingWidgetState = () => let amountAvailable = 0; - for (const inventoryItem of inventoryItems) amountAvailable += inventoryItem.items.length; + if (inventoryItems) for (const inventoryItem of inventoryItems) amountAvailable += inventoryItem.items.length; newValue.push({ name: name,