Răsfoiți Sursa

Can now create new transactions

Lee Morgan 5 ani în urmă
părinte
comite
32873f6e28

+ 5 - 2
views/dashboardPage/bundle.js

@@ -429,7 +429,7 @@ class Merchant{
         for(let i = 0; i < transaction.recipes.length; i++){
             const recipe = transaction.recipes[i];
             for(let j = 0; j < recipe.recipe.ingredients.length; j++){
-                const ingredient = recipe.ingredients[i];
+                const ingredient = recipe.recipe.ingredients[i];
                 if(ingredients[ingredient.ingredient.id]){
                     ingredients[ingredient.ingredient.id] += recipe.quantity * ingredient.quantity;
                 }else{
@@ -3060,10 +3060,13 @@ let newTransaction = {
                         );
 
                         merchant.addTransaction(transaction);
-                        banner.createNotification("NEW TRANSACTION CREATED, INGREDIENTS UPDATED ACCORDINGLY");
+
+                        controller.openStrand("transactions");
+                        banner.createNotification("TRANSACTION CREATED");
                     }
                 })
                 .catch((err)=>{
+                    console.log(err);
                     banner.createError("SOMETHING WENT WRONG. PLEASE REFRESH THE PAGE");
                 })
                 .finally(()=>{

+ 1 - 1
views/dashboardPage/js/Merchant.js

@@ -302,7 +302,7 @@ class Merchant{
         for(let i = 0; i < transaction.recipes.length; i++){
             const recipe = transaction.recipes[i];
             for(let j = 0; j < recipe.recipe.ingredients.length; j++){
-                const ingredient = recipe.ingredients[i];
+                const ingredient = recipe.recipe.ingredients[i];
                 if(ingredients[ingredient.ingredient.id]){
                     ingredients[ingredient.ingredient.id] += recipe.quantity * ingredient.quantity;
                 }else{

+ 4 - 1
views/dashboardPage/js/newTransaction.js

@@ -71,10 +71,13 @@ let newTransaction = {
                         );
 
                         merchant.addTransaction(transaction);
-                        banner.createNotification("NEW TRANSACTION CREATED, INGREDIENTS UPDATED ACCORDINGLY");
+
+                        controller.openStrand("transactions");
+                        banner.createNotification("TRANSACTION CREATED");
                     }
                 })
                 .catch((err)=>{
+                    console.log(err);
                     banner.createError("SOMETHING WENT WRONG. PLEASE REFRESH THE PAGE");
                 })
                 .finally(()=>{