Browse Source

Organize home controller

Lee Morgan 6 years ago
parent
commit
d1048df5eb
2 changed files with 16 additions and 16 deletions
  1. 12 12
      controllers/home.js
  2. 4 4
      routes.js

+ 12 - 12
controllers/home.js

@@ -75,7 +75,18 @@ module.exports = {
             })
     },
 
-    getRecipes: function(req, res){
+    updateMerchant: function(req, res){
+        Merchant.updateOne({_id: req.body._id}, req.body)
+            .then((merchant)=>{
+                return res.json(merchant);
+            })
+            .catch((err)=>{
+                console.log(err);
+                return res.render("error");
+            });
+    },
+
+    getCloverRecipes: function(req, res){
         axios.get(`https://apisandbox.dev.clover.com/v3/merchants/${merchantId}/items?access_token=${token}`)
             .then((recipes)=>{
                 return res.json(recipes);
@@ -197,17 +208,6 @@ module.exports = {
             });
     },
 
-    updateMerchant: function(req, res){
-        Merchant.updateOne({_id: req.body._id}, req.body)
-            .then((merchant)=>{
-                return res.json(merchant);
-            })
-            .catch((err)=>{
-                console.log(err);
-                return res.render("error");
-            });
-    },
-
     updateRecipes: function(req, res){
         Merchant.findOne({posId: merchantId})
             .then((merchant)=>{

+ 4 - 4
routes.js

@@ -3,12 +3,12 @@ const home = require("./controllers/home");
 module.exports = function(app){
     app.get("/", home.displayInventory);
     app.get("/merchant/new", home.merchantSetup);
-    app.get("/getrecipes", home.getRecipes);
+    app.get("/getrecipes", home.getCloverRecipes);
     app.post("/merchant/create", home.createMerchant);
     app.post("/merchant/update", home.updateMerchant);
-    app.post("/ingredients/create", home.createNewIngredients);
-    app.post("/ingredients/createone", home.createIngredient);
+    app.post("/ingredients/create", home.createNewIngredients);  //update?
+    app.post("/ingredients/createone", home.createIngredient);  //update?
     app.get("/recipes", home.displayRecipes);
-    app.post("/recipes/ingredients/remove", home.deleteRecipeIngredient);
+    app.post("/recipes/ingredients/remove", home.deleteRecipeIngredient);  //update?
     app.get("/recipes/update", home.updateRecipes);
 }