Prechádzať zdrojové kódy

Saving changes until I get feeback on the spreadsheet layout

Lee Morgan 5 rokov pred
rodič
commit
c887a150e6

+ 33 - 33
controllers/recipeData.js

@@ -335,38 +335,38 @@ module.exports = {
         }
 
         //Create Recipes
-        let merchant = {};
-        let newRecipes = [];
-        return Merchant.findOne({_id: user})
-            .then((response)=>{
-                merchant = response;
-
-                let recipes = [];
-                for(let i = 1; i < array.length; i++){
-                    recipes.push({
-                        name: array[i][locations.name],
-                        price: parseInt(array[i][locations.price] * 100),
-                        merchant: merchant
-                    });
-                }
-
-                return Recipe.create(recipes)
-            })
-            .then((recipes)=>{
-                for(let i = 0; i < recipes.length; i++){
-                    merchant.recipes.push(recipes[i]);
-
-                    recipes[i].merchant = undefined;
-                    newRecipes.push(recipes[i]);
-                }
-
-                return merchant.save();
-            })
-            .then((merchant)=>{
-                return newRecipes;
-            })
-            .catch((err)=>{
-                return "ERROR: UNABLE TO CREATE RECIPES";
-            });
+        // let merchant = {};
+        // let newRecipes = [];
+        // return Merchant.findOne({_id: req.session.user})
+        //     .then((response)=>{
+        //         merchant = response;
+
+        //         let recipes = [];
+        //         for(let i = 1; i < array.length; i++){
+        //             recipes.push({
+        //                 name: array[i][locations.name],
+        //                 price: parseInt(array[i][locations.price] * 100),
+        //                 merchant: merchant
+        //             });
+        //         }
+
+        //         return Recipe.create(recipes)
+        //     })
+        //     .then((recipes)=>{
+        //         for(let i = 0; i < recipes.length; i++){
+        //             merchant.recipes.push(recipes[i]);
+
+        //             recipes[i].merchant = undefined;
+        //             newRecipes.push(recipes[i]);
+        //         }
+
+        //         return merchant.save();
+        //     })
+        //     .then((merchant)=>{
+        //         return newRecipes;
+        //     })
+        //     .catch((err)=>{
+        //         return "ERROR: UNABLE TO CREATE RECIPES";
+        //     });
     }
 }

+ 2 - 2
routes.js

@@ -30,7 +30,7 @@ module.exports = function(app){
     app.post("/ingredients/create", ingredientData.createIngredient);  //also adds to merchant
     app.put("/ingredients/update", ingredientData.updateIngredient);
     app.delete("/ingredients/remove/:id", ingredientData.removeIngredient);
-    app.post("/ingredients/create/spreadsheet", upload.single("spreadsheet"), ingredientData.createFromSpreadsheet);
+    app.post("/ingredients/create/spreadsheet", upload.single("ingredients"), ingredientData.createFromSpreadsheet);
 
     //Recipes
     app.post("/recipe/create", recipeData.createRecipe);
@@ -38,7 +38,7 @@ module.exports = function(app){
     app.delete("/recipe/remove/:id", recipeData.removeRecipe);
     app.get("/recipe/update/clover", recipeData.updateRecipesClover);
     app.get("/recipe/update/square", recipeData.updateRecipesSquare);
-    app.post("/recipes/create/spreadsheet", upload.single("spreadsheet"), recipeData.createFromSpreadsheet);
+    app.post("/recipes/create/spreadsheet", upload.single("recipes"), recipeData.createFromSpreadsheet);
 
     //Orders
     app.get("/order", orderData.getOrders);

+ 3 - 1
views/dashboardPage/bundle.js

@@ -1493,7 +1493,7 @@ controller = {
             case "recipeSpreadsheet":
                 let form = document.getElementById("modalSpreadsheetUpload");
                 form.style.display = "flex";
-                form.onsubmit = newRecipe.submitSpreadsheet();
+                form.onsubmit = newRecipe.submitSpreadsheet;
                 break;
         }
     },
@@ -2370,7 +2370,9 @@ let newRecipe = {
 
         const file = document.getElementById("spreadsheetInput").files[0];
         let data = new FormData();
+        console.log(file);
         data.append("recipes", file);
+        console.log(data);
 
         let loader = document.getElementById("loaderContainer");
         loader.style.display = "flex";

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

@@ -199,7 +199,7 @@ controller = {
             case "recipeSpreadsheet":
                 let form = document.getElementById("modalSpreadsheetUpload");
                 form.style.display = "flex";
-                form.onsubmit = newRecipe.submitSpreadsheet();
+                form.onsubmit = newRecipe.submitSpreadsheet;
                 break;
         }
     },

+ 2 - 0
views/dashboardPage/js/sidebars/newRecipe.js

@@ -134,7 +134,9 @@ let newRecipe = {
 
         const file = document.getElementById("spreadsheetInput").files[0];
         let data = new FormData();
+        console.log(file);
         data.append("recipes", file);
+        console.log(data);
 
         let loader = document.getElementById("loaderContainer");
         loader.style.display = "flex";