Ver Fonte

Update Order class to find the Ingredients rather than needing to pass Ingredients in.

Lee Morgan há 5 anos atrás
pai
commit
b368b99237
2 ficheiros alterados com 22 adições e 10 exclusões
  1. 11 5
      views/dashboardPage/bundle.js
  2. 11 5
      views/dashboardPage/js/Order.js

+ 11 - 5
views/dashboardPage/bundle.js

@@ -926,11 +926,17 @@ class Order{
         }
 
         for(let i = 0; i < ingredients.length; i++){
-            this._ingredients.push(new OrderIngredient(
-                ingredients[i].ingredient,
-                ingredients[i].quantity,
-                ingredients[i].pricePerUnit
-            ));
+            for(let j = 0; j < merchant.ingredients.length; j++){
+                if(merchant.ingredients[j].ingredient.id === ingredients[i].ingredient){
+                    this._ingredients.push(new OrderIngredient(
+                        merchant.ingredients[j].ingredient,
+                        ingredients[i].quantity,
+                        ingredients[i].pricePerUnit
+                    ));
+                    break;
+                }
+            }
+            
         }
 
         this._parent.modules.ingredients.isPopulated = false;

+ 11 - 5
views/dashboardPage/js/Order.js

@@ -133,11 +133,17 @@ class Order{
         }
 
         for(let i = 0; i < ingredients.length; i++){
-            this._ingredients.push(new OrderIngredient(
-                ingredients[i].ingredient,
-                ingredients[i].quantity,
-                ingredients[i].pricePerUnit
-            ));
+            for(let j = 0; j < merchant.ingredients.length; j++){
+                if(merchant.ingredients[j].ingredient.id === ingredients[i].ingredient){
+                    this._ingredients.push(new OrderIngredient(
+                        merchant.ingredients[j].ingredient,
+                        ingredients[i].quantity,
+                        ingredients[i].pricePerUnit
+                    ));
+                    break;
+                }
+            }
+            
         }
 
         this._parent.modules.ingredients.isPopulated = false;