Эх сурвалжийг харах

Fix bug in the creation of the spreadsheet template for recipes.

Lee Morgan 5 жил өмнө
parent
commit
395fee9589

+ 7 - 1
controllers/recipeData.js

@@ -415,7 +415,7 @@ module.exports = {
             req.session.error = "MUST BE LOGGED IN TO DO THAT";
             return res.redirect("/");
         }
-
+        
         Merchant.findOne({_id: req.session.user})
             .populate("inventory.ingredient")
             .then((merchant)=>{
@@ -429,6 +429,12 @@ module.exports = {
                     workbookData.push(["", "", "", "", "", merchant.inventory[i].ingredient.name, merchant.inventory[i].defaultUnit]);
                 }
 
+                if(workbookData.length < 5){
+                    for(let i = workbookData.length - 1; i < 5; i++){
+                        workbookData.push(["", "", "", ""]);
+                    }
+                }
+
                 workbookData[1][0] = "Example Recipe 1";
                 workbookData[1][1] = 10.98;
                 workbookData[1][2] = "Example Ingredient 1";