Forráskód Böngészése

Fix small error when uploading recipes from a spreadsheet.

Lee Morgan 5 éve
szülő
commit
6395dff8c6
2 módosított fájl, 6 hozzáadás és 1 törlés
  1. 1 0
      controllers/ingredientData.js
  2. 5 1
      controllers/recipeData.js

+ 1 - 0
controllers/ingredientData.js

@@ -156,6 +156,7 @@ module.exports = {
                 unitType: helper.getUnitType(array[i][locations.unit].toLowerCase())
             });
 
+            console.log(array[i][locations.unit]);
             if(array[i][locations.unit] === "bottle"){
                 ingredient.unitType = array[i][locations.bottleUnit];
                 ingredient.unitSize = helper.convertQuantityToBaseUnit(array[i][locations.bottleSize], array[i][locations.bottleUnit]);

+ 5 - 1
controllers/recipeData.js

@@ -137,7 +137,11 @@ module.exports = {
         //get property locations
         let locations = {};
         for(let i = 0; i < array[0].length; i++){
-            switch(array[0][i].toLowerCase()){
+            let title = "";
+            try{title = array[0][i].toLowerCase()}
+            catch{title = ""}
+
+            switch(title){
                 case "name": locations.name = i; break;
                 case "price": locations.price = i; break;
                 case "ingredients": locations.ingredient = i; break;