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

Transactions fully updated to a working state

Lee Morgan преди 5 години
родител
ревизия
0d6decbf1a
променени са 3 файла, в които са добавени 16 реда и са изтрити 2 реда
  1. 8 1
      views/dashboardPage/bundle.js
  2. 5 1
      views/dashboardPage/js/Merchant.js
  3. 3 0
      views/dashboardPage/js/transactionDetails.js

+ 8 - 1
views/dashboardPage/bundle.js

@@ -407,13 +407,17 @@ class Merchant{
     }
 
     getTransactions(from = 0, to = new Date()){
+        if(merchant._transactions.length <= 0){
+            return [];
+        }
+
         if(from === 0){
             from = this._transactions[this._transactions.length-1].date;
         }
 
         const {start, end} = this.getTransactionIndices(from, to);
 
-        return this._transactions.slice(start, end);
+        return this._transactions.slice(start, end + 1);
     }
 
     addTransaction(transaction){
@@ -3609,10 +3613,13 @@ let transactionDetails = {
                     banner.createError(response);
                 }else{
                     merchant.removeTransaction(this.transaction);
+
+                    controller.openStrand("transactions");
                     banner.createNotification("TRANSACTION REMOVED");
                 }
             })
             .catch((err)=>{
+                console.log(err);
                 banner.createError("SOMETHING WENT WRONG. PLEASE REFRESH THE PAGE");
             })
             .finally(()=>{

+ 5 - 1
views/dashboardPage/js/Merchant.js

@@ -280,13 +280,17 @@ class Merchant{
     }
 
     getTransactions(from = 0, to = new Date()){
+        if(merchant._transactions.length <= 0){
+            return [];
+        }
+
         if(from === 0){
             from = this._transactions[this._transactions.length-1].date;
         }
 
         const {start, end} = this.getTransactionIndices(from, to);
 
-        return this._transactions.slice(start, end);
+        return this._transactions.slice(start, end + 1);
     }
 
     addTransaction(transaction){

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

@@ -56,10 +56,13 @@ let transactionDetails = {
                     banner.createError(response);
                 }else{
                     merchant.removeTransaction(this.transaction);
+
+                    controller.openStrand("transactions");
                     banner.createNotification("TRANSACTION REMOVED");
                 }
             })
             .catch((err)=>{
+                console.log(err);
                 banner.createError("SOMETHING WENT WRONG. PLEASE REFRESH THE PAGE");
             })
             .finally(()=>{