Ver Fonte

Bug fix: errors on frontend if no address.

Lee Morgan há 5 anos atrás
pai
commit
69639eba98

+ 1 - 3
controllers/merchantData.js

@@ -218,9 +218,7 @@ module.exports = {
                 return res.redirect("/login");
             })
             .catch((err)=>{
-                if(typeof(err) === "string"){
-                    return res.json(err);
-                }
+                if(typeof(err) === "string") return res.json(err);
                 if(err.name === "ValidationError"){
                     return res.json(err.errors[Object.keys(err.errors)[0]].properties.message);
                 }

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

@@ -23,14 +23,13 @@ const modalScript = require("./modal.js");
 
 const Merchant = require("./classes/Merchant.js");
 
-console.log(data);
 window.merchant = new Merchant(
     data.merchant.name,
     data.merchant.pos,
     data.merchant.inventory,
     data.merchant.recipes,
     data.transactions,
-    data.merchant.address.full,
+    (data.merchant.address === undefined) ? "" : data.merchant.address.full,
     data.owner
 );
 

+ 2 - 2
views/dashboardPage/js/modal.js

@@ -77,7 +77,7 @@ let modal = {
                         response[1].inventory,
                         response[1].recipes,
                         [],
-                        response[1].address,
+                        (response[1].address === undefined) ? "" : response[1].address.full,
                         response[0]
                     );
 
@@ -135,7 +135,7 @@ let modal = {
                         response[1].inventory,
                         response[1].recipes,
                         [],
-                        response[1].address,
+                        (response[1].address === undefined) ? "" : response[1].address.full,
                         response[0]
                     );
 

+ 2 - 2
views/dashboardPage/js/strands/account.js

@@ -144,7 +144,7 @@ let account = {
                         response[1].inventory,
                         response[1].recipes,
                         response[2],
-                        response[1].address,
+                        (response[1].address === undefined) ? "" : response[1].address.full,
                         response[0]
                     );
 
@@ -176,7 +176,7 @@ let account = {
                         response[1].inventory,
                         response[1].recipes,
                         response[2],
-                        response[1].address,
+                        (response[1].address === undefined) ? "" : response[1].address.full,
                         response[0]
                     );
                     state.updateMerchant();