Lee Morgan 6 лет назад
Родитель
Сommit
822af56782
2 измененных файлов с 4 добавлено и 3 удалено
  1. 1 1
      views/dashboardPage/Merchant.js
  2. 3 2
      views/dashboardPage/components/components.js

+ 1 - 1
views/dashboardPage/Merchant.js

@@ -106,6 +106,7 @@ class Merchant{
     remove = set true if removing
     */
     addIngredients(ingredients, remove = false){
+        console.log(ingredients);
         for(let i = 0; i < ingredients.length; i++){
             let isNew = true;
             for(let j = 0; j < merchant.ingredients.length; j++){
@@ -129,7 +130,6 @@ class Merchant{
             }
         }
     
-        console.log("added");
         homeStrandObj.drawInventoryCheckCard();
         ingredientsStrandObj.populateByProperty("category");
         addIngredientsComp.isPopulated = false;

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

@@ -558,6 +558,7 @@ let ingredientDetailsComp = {
 
     display: function(ingredient, category){
         this.ingredient = ingredient;
+        console.log(ingredient);
 
         sidebar = document.querySelector("#ingredientDetails");
 
@@ -617,7 +618,7 @@ let ingredientDetailsComp = {
             }
         }
 
-        fetch(`/merchant/ingredients/remove/${this.ingredient.id}`, {
+        fetch(`/merchant/ingredients/remove/${this.ingredient.ingredient.id}`, {
             method: "DELETE",
         })
             .then((response) => response.json())
@@ -626,7 +627,7 @@ let ingredientDetailsComp = {
                     banner.createError(response);
                 }else{
                     banner.createNotification("Ingredient removed");
-                    updateInventory([this.ingredient], true);
+                    merchant.addIngredients([this.ingredient], true);
                 }
             })
             .catch((err)=>{});