Преглед на файлове

Fix bug in Merchant class

Lee Morgan преди 5 години
родител
ревизия
7c808a1023
променени са 3 файла, в които са добавени 8 реда и са изтрити 70 реда
  1. 0 62
      views/dashboardPage/bundle.js
  2. 7 8
      views/dashboardPage/js/Merchant.js
  3. 1 0
      views/dashboardPage/js/ingredientDetails.js

Файловите разлики са ограничени, защото са твърде много
+ 0 - 62
views/dashboardPage/bundle.js


+ 7 - 8
views/dashboardPage/js/Merchant.js

@@ -1,7 +1,6 @@
 const Ingredient = require("./Ingredient.js");
 const Recipe = require("./Recipe.js");
 const Transaction = require("./Transaction.js");
-const merchant = require("../../../models/merchant.js");
 
 class Merchant{
     constructor(oldMerchant, transactions){
@@ -66,14 +65,14 @@ class Merchant{
     editIngredients(ingredients, remove = false, isOrder = false){
         for(let i = 0; i < ingredients.length; i++){
             let isNew = true;
-            for(let j = 0; j < merchant.ingredients.length; j++){
-                if(merchant.ingredients[j].ingredient === ingredients[i].ingredient){
+            for(let j = 0; j < this.ingredients.length; j++){
+                if(this.ingredients[j].ingredient === ingredients[i].ingredient){
                     if(remove){
-                        merchant.ingredients.splice(j, 1);
+                        this.ingredients.splice(j, 1);
                     }else if(!remove && isOrder){
-                        merchant.ingredients[j].quantity += ingredients[i].quantity;
+                        this.ingredients[j].quantity += ingredients[i].quantity;
                     }else{
-                        merchant.ingredients[j].quantity = ingredients[i].quantity;
+                        this.ingredients[j].quantity = ingredients[i].quantity;
                     }
     
                     isNew = false;
@@ -82,7 +81,7 @@ class Merchant{
             }
     
             if(isNew){
-                merchant.ingredients.push({
+                this.ingredients.push({
                     ingredient: ingredients[i].ingredient,
                     quantity: parseFloat(ingredients[i].quantity),
                     defaultUnit: ingredients[i].defaultUnit
@@ -118,7 +117,7 @@ class Merchant{
             }
 
             if(isNew){
-                merchant.recipes.push(recipes[i]);
+                this.recipes.push(recipes[i]);
             }
         }
 

+ 1 - 0
views/dashboardPage/js/ingredientDetails.js

@@ -194,6 +194,7 @@ let ingredientDetails = {
                 }
             })
             .catch((err)=>{
+                console.log(err);
                 banner.createError("SOMETHING WENT WRONG. PLEASE REFRESH THE PAGE");
             })
             .finally(()=>{

Някои файлове не бяха показани, защото твърде много файлове са промени