Lee Morgan 6 лет назад
Родитель
Сommit
843f647cbe

+ 6 - 8
views/dashboardPage/Merchant.js

@@ -99,14 +99,11 @@ class Merchant{
     /*
     /*
     Updates all specified item in the merchant's inventory and updates the page
     Updates all specified item in the merchant's inventory and updates the page
     If ingredient doesn't exist, add it
     If ingredient doesn't exist, add it
-    Inputs:
-    Array of objects
-        id: id of ingredient
-        quantity: change in quantity (if not removing)
-        name: name of ingredient (only for new ingredient)
-        category: category of ingredient (only for new ingredient)
-        unit: unit of measurement (only for new ingredient)
-    remove: if true, remove ingredient from inventory
+    ingredients = {
+        ingredient: Ingredient object,
+        quantity: change in quantity
+    }
+    remove = set true if removing
     */
     */
     addIngredients(ingredients, remove = false){
     addIngredients(ingredients, remove = false){
         for(let i = 0; i < ingredients.length; i++){
         for(let i = 0; i < ingredients.length; i++){
@@ -132,6 +129,7 @@ class Merchant{
             }
             }
         }
         }
     
     
+        console.log("added");
         homeStrandObj.drawInventoryCheckCard();
         homeStrandObj.drawInventoryCheckCard();
         ingredientsStrandObj.populateByProperty("category");
         ingredientsStrandObj.populateByProperty("category");
         addIngredientsComp.isPopulated = false;
         addIngredientsComp.isPopulated = false;

+ 10 - 3
views/dashboardPage/components/components.js

@@ -288,7 +288,16 @@ let newIngredientComp = {
                     if(typeof(response) === "string"){
                     if(typeof(response) === "string"){
                         banner.createError(response);
                         banner.createError(response);
                     }else{
                     }else{
-                        updateInventory([response]);
+                        merchant.addIngredients([{
+                            ingredient: new Ingredient(
+                                response.ingredient._id,
+                                response.ingredient.name,
+                                response.ingredient.category,
+                                response.ingredient.unit
+                            ),
+                            quantity: response.quantity
+                        }]);
+
                         banner.createNotification("Ingredient successfully created");
                         banner.createNotification("Ingredient successfully created");
                     }
                     }
                 })
                 })
@@ -539,7 +548,6 @@ let addIngredientsComp = {
                 }
                 }
             })
             })
             .catch((err)=>{
             .catch((err)=>{
-                console.log(err);
                 banner.createError("Something went wrong.  Try refreshing the page");
                 banner.createError("Something went wrong.  Try refreshing the page");
             });
             });
     }
     }
@@ -654,7 +662,6 @@ let ingredientDetailsComp = {
                     }
                     }
                 })
                 })
                 .catch((err)=>{
                 .catch((err)=>{
-                    console.log(err);
                     banner.createError("Something went wrong, try refreshing the page");
                     banner.createError("Something went wrong, try refreshing the page");
                 });
                 });
         }
         }

+ 0 - 3
views/dashboardPage/ingredients.js

@@ -11,10 +11,8 @@ window.ingredientsStrandObj = {
     },
     },
 
 
     populateByProperty: function(property){
     populateByProperty: function(property){
-        console.log("populate by property");
         let categories;
         let categories;
         if(property === "category"){
         if(property === "category"){
-            console.log("categorizing");
             categories = merchant.categorizeIngredients();
             categories = merchant.categorizeIngredients();
         }else if(property === "unit"){
         }else if(property === "unit"){
             categories = unitizeIngredients(merchant.inventory);
             categories = unitizeIngredients(merchant.inventory);
@@ -51,7 +49,6 @@ window.ingredientsStrandObj = {
             }
             }
         }
         }
 
 
-        console.log("done");
     },
     },
 
 
     displayIngredientsOnly: function(ingredients){
     displayIngredientsOnly: function(ingredients){