Преглед на файлове

Bug fix: errors on frontend if no address.

Lee Morgan преди 5 години
родител
ревизия
69639eba98
променени са 4 файла, в които са добавени 6 реда и са изтрити 9 реда
  1. 1 3
      controllers/merchantData.js
  2. 1 2
      views/dashboardPage/js/dashboard.js
  3. 2 2
      views/dashboardPage/js/modal.js
  4. 2 2
      views/dashboardPage/js/strands/account.js

+ 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();