From 4dbcde8e35fc010612f2eb62b5bf24d788b2f253 Mon Sep 17 00:00:00 2001 From: Joshua Sigona Date: Fri, 10 Sep 2021 19:38:31 +0900 Subject: [PATCH] Update FOODCOUNT counter --- src/TestPanel.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/TestPanel.js b/src/TestPanel.js index 951c770..e4d111c 100644 --- a/src/TestPanel.js +++ b/src/TestPanel.js @@ -373,6 +373,7 @@ function FoodPopupWindow(p) { const MAX_SELECTED=10; const [FOODLIST,setFOODLIST] = useState(Object.keys(GetData("food"))) const [FOODS,setFOODS] = useState(GetData("food")) + const FOODCOUNT = Object.keys(foodPointData).reduce((total,food)=>foodPointData[food]+total,0) useEffect(()=>{ setFOODLIST(Object.keys(GetData("food"))) @@ -381,15 +382,14 @@ function FoodPopupWindow(p) { function modifyPoints(foodName,add) { var temp = {...foodPointData} - var total = Object.keys(foodPointData).reduce((total,food)=>foodPointData[food]+total,0) - console.log(total) + var total = FOODCOUNT if (add+total<=10&&add+total>=0) { temp[foodName] = Math.min(Math.max((temp[foodName]??0)+add,0),MAX_SELECTED) setFoodPointData(temp) } } - return
Foods in Recipe
0
Confirm
Cancel
}> + return
Foods in Recipe
{FOODCOUNT}
Confirm
Cancel
}> {FOODLIST.map((key)=>)}
}