Explorar o código

Update how recipes check for ingredient units not matching.

Lee Morgan %!s(int64=5) %!d(string=hai) anos
pai
achega
64d33eba6e
Modificáronse 1 ficheiros con 7 adicións e 1 borrados
  1. 7 1
      views/dashboardPage/js/sidebars/newRecipe.js

+ 7 - 1
views/dashboardPage/js/sidebars/newRecipe.js

@@ -85,8 +85,14 @@ let newRecipe = {
             // }else{
             // }else{
             //     newIngredient.baseUnitMultiplier = 1 / controller.baseUnit(1, newIngredient.unit);
             //     newIngredient.baseUnitMultiplier = 1 / controller.baseUnit(1, newIngredient.unit);
             // }
             // }
-
             
             
+            if(["g", "kg", "oz", "lb"].includes(newIngredient.unit) && ingredient.toMass === undefined){
+                mismatchUnits.push({ingredient: ingredient, newIngredient: newIngredient});
+            }else if(["ml", "l", "tsp", "tbsp", "ozfl", "cup", "pt", "qt", "gal"].includes(newIngredient.unit) && ingredient.toVolume === undefined){
+                mismatchUnits.push({ingredient: ingredient, newIngredient: newIngredient});
+            }else if(["mm", "cm", "m", "in", "ft"].includes(newIngredient.unit) && ingredient.toLength === undefined){
+                mismatchUnits.push({ingredient: ingredient, newIngredient: newIngredient});
+            }
     
     
             data.ingredients.push(newIngredient);
             data.ingredients.push(newIngredient);
         }
         }