Pārlūkot izejas kodu

Bug fix: Transactions were not properly deleting.

Lee Morgan 11 mēneši atpakaļ
vecāks
revīzija
d1aa3a2900

+ 3 - 5
src/views/js/data/Transaction.js

@@ -68,9 +68,6 @@ export default class Transaction{
     }
 
     static async fetch(account, from, to){
-        console.log(account);
-        console.log(from);
-        console.log(to);
         let response;
         try{
             response = await fetch("/api/transaction/search", {
@@ -79,7 +76,6 @@ export default class Transaction{
                 body: JSON.stringify({account, from, to})
             });
             response = await response.json();
-            console.log(response);
 
             const promises = [];
             for(let i = 0; i < response.length; i++){
@@ -121,13 +117,15 @@ export default class Transaction{
     }
 
     async delete(){
-        let response = await fetch(`/api/transactions/${this._id}`, {
+        let response = await fetch(`/api/transaction/${this._id}`, {
             method: "DELETE",
             headers: {"Content-Type": "application/json"}
         });
         response = await response.json(); 
 
         if(response.error) throw response.error;
+
+        this._parent.removeTransaction(this);
     }
 
     async save(isNew = false){

+ 2 - 2
src/views/js/pages/TransactionDetails.js

@@ -1,6 +1,7 @@
 import Page from "./Page.js";
 import Elem from "../Elem.js";
 import Format from "../Format.js";
+import Notifier from "../Notifier.js";
 
 export default class TransactionDetails extends Page{
     constructor(transaction){
@@ -37,8 +38,7 @@ export default class TransactionDetails extends Page{
 
     async delete(transaction){
         try{
-            const response = await transaction.delete();
-            if(response.error) throw response.error;
+            await transaction.delete();
         }catch(e){
             if(e.error){
                 new Notifier("error", e.error.message);