Parcourir la source

Various bug fixes. Remove unnecessary console logs

Lee Morgan il y a 6 ans
Parent
commit
4fac18b0b8
2 fichiers modifiés avec 18 ajouts et 12 suppressions
  1. 1 8
      views/inventory/inventory.js
  2. 17 4
      views/merchantSetupPage/merchantSetup.js

+ 1 - 8
views/inventory/inventory.js

@@ -1,6 +1,5 @@
 let items = [];
 let tbody = document.querySelector("tbody");
-console.log(merchant);
 
 let renderIngredients = ()=>{
     while(tbody.hasChildNodes()){
@@ -99,9 +98,7 @@ let updateOne = (id, row)=>{
         id: id,
         quantity: quantity
     })
-        .then((ingredient)=>{
-            // console.log(ingredient);
-        })
+        .then((ingredient)=>{})
         .catch((err)=>{
             console.log(err);
         });
@@ -110,7 +107,6 @@ let updateOne = (id, row)=>{
 let removeIngredient = (id, row)=>{
     axios.post("/ingredients/remove", {id: id})
         .then((result)=>{
-            console.log(result);
             for(let i = 0; i < items.length; i++){
                 if(id === items[i].id){
                     items.splice(i, 1);
@@ -147,11 +143,8 @@ let addIngredient = ()=>{
         quantity: content.children[2].children[0].value
     }
 
-    console.log(newIngredient);
-
     axios.post("/ingredients/createone", newIngredient)
         .then((ingredient)=>{
-            console.log(ingredient);
             items.push({
                 id: ingredient._id,
                 name: newIngredient.ingredient.name,

+ 17 - 4
views/merchantSetupPage/merchantSetup.js

@@ -1,7 +1,5 @@
 let state = 0;
 let data = {};
-console.log(ingredients);
-console.log(recipes);
 
 let addIngredients = document.querySelector("#addIngredients");
 let newIngredients = document.querySelector("#newIngredients");
@@ -117,7 +115,7 @@ let newIngredientField = ()=>{
 }
 
 let createIngredientsList = ()=>{
-    data.ingredients = [];  //changed
+    data.ingredients = [];
     for(let ingredient of existingIngredientElements){
         if(ingredient.childNodes[0].childNodes[0].checked){
             data.ingredients.push({
@@ -180,11 +178,13 @@ let showRecipe = ()=>{
         let ingTd = document.createElement("td");
         row.appendChild(ingTd);
         let ingName = document.createElement("select");
-        console.log(data.ingredients);
         for(let ingredient of data.ingredients){
             let newOption = document.createElement("option");
             newOption.innerText = ingredient.name;
             newOption.value = ingredient.id;
+            if(ingredient.id === ing.id){
+                newOption.selected = "selected";
+            }
             ingName.appendChild(newOption);
         }
         ingTd.appendChild(ingName);
@@ -260,8 +260,21 @@ let changeRecipe = (num)=>{
 }
 
 let submitAll = ()=>{
+    let body = document.querySelector("#recipes tbody");
     data.recipes = [];
 
+    let recipeIngredients = [];
+    while(body.hasChildNodes()){
+        let row = body.firstChild;
+        recipeIngredients.push({
+            id: row.childNodes[0].childNodes[0].value,
+            quantity: row.childNodes[1].childNodes[0].value
+        });
+        recipeData[recipeDataIndex].ingredients = recipeIngredients;
+
+        body.removeChild(row);
+    }
+
     for(let recipe of recipeData){
         let newRecipe = {
             cloverId: recipe.id,