Explorar o código

Recipe analysis breaks when no transactions. Bug fixed.

Lee Morgan %!s(int64=5) %!d(string=hai) anos
pai
achega
6a50064ba9

+ 4 - 3
views/dashboardPage/bundle.js

@@ -1462,8 +1462,11 @@ let analytics = {
     recipeDisplay: function(){
     recipeDisplay: function(){
         let quantities = [];
         let quantities = [];
         let dates = [];
         let dates = [];
-        let currentDate = this.transactions[0].date;
+        let currentDate;
         let quantity = 0;
         let quantity = 0;
+        if(this.transactions.length > 0){
+            currentDate = this.transactions[0].date;
+        }
 
 
         for(let i = 0; i < this.transactions.length; i++){
         for(let i = 0; i < this.transactions.length; i++){
             if(currentDate.getDate() !== this.transactions[i].date.getDate()){
             if(currentDate.getDate() !== this.transactions[i].date.getDate()){
@@ -3070,7 +3073,6 @@ let newTransaction = {
                     }
                     }
                 })
                 })
                 .catch((err)=>{
                 .catch((err)=>{
-                    console.log(err);
                     banner.createError("SOMETHING WENT WRONG. PLEASE REFRESH THE PAGE");
                     banner.createError("SOMETHING WENT WRONG. PLEASE REFRESH THE PAGE");
                 })
                 })
                 .finally(()=>{
                 .finally(()=>{
@@ -3619,7 +3621,6 @@ let transactionDetails = {
                 }
                 }
             })
             })
             .catch((err)=>{
             .catch((err)=>{
-                console.log(err);
                 banner.createError("SOMETHING WENT WRONG. PLEASE REFRESH THE PAGE");
                 banner.createError("SOMETHING WENT WRONG. PLEASE REFRESH THE PAGE");
             })
             })
             .finally(()=>{
             .finally(()=>{

+ 4 - 1
views/dashboardPage/js/analytics.js

@@ -204,8 +204,11 @@ let analytics = {
     recipeDisplay: function(){
     recipeDisplay: function(){
         let quantities = [];
         let quantities = [];
         let dates = [];
         let dates = [];
-        let currentDate = this.transactions[0].date;
+        let currentDate;
         let quantity = 0;
         let quantity = 0;
+        if(this.transactions.length > 0){
+            currentDate = this.transactions[0].date;
+        }
 
 
         for(let i = 0; i < this.transactions.length; i++){
         for(let i = 0; i < this.transactions.length; i++){
             if(currentDate.getDate() !== this.transactions[i].date.getDate()){
             if(currentDate.getDate() !== this.transactions[i].date.getDate()){

+ 0 - 1
views/dashboardPage/js/newTransaction.js

@@ -77,7 +77,6 @@ let newTransaction = {
                     }
                     }
                 })
                 })
                 .catch((err)=>{
                 .catch((err)=>{
-                    console.log(err);
                     banner.createError("SOMETHING WENT WRONG. PLEASE REFRESH THE PAGE");
                     banner.createError("SOMETHING WENT WRONG. PLEASE REFRESH THE PAGE");
                 })
                 })
                 .finally(()=>{
                 .finally(()=>{

+ 0 - 1
views/dashboardPage/js/transactionDetails.js

@@ -62,7 +62,6 @@ let transactionDetails = {
                 }
                 }
             })
             })
             .catch((err)=>{
             .catch((err)=>{
-                console.log(err);
                 banner.createError("SOMETHING WENT WRONG. PLEASE REFRESH THE PAGE");
                 banner.createError("SOMETHING WENT WRONG. PLEASE REFRESH THE PAGE");
             })
             })
             .finally(()=>{
             .finally(()=>{