From c9f7140d9558ab4d0249f03d3a0ed82a40994c75 Mon Sep 17 00:00:00 2001 From: padreug Date: Wed, 18 Jun 2025 10:08:44 +0200 Subject: [PATCH] Refactor total DCA balance calculation: remove redundant state variable and update computed property to directly calculate balance from deposits. --- static/js/index.js | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/static/js/index.js b/static/js/index.js index ebdaa3b..ad6fbe4 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -7,7 +7,6 @@ window.app = Vue.createApp({ // DCA Admin Data dcaClients: [], deposits: [], - totalDcaBalance: 0, // Table configurations clientsTable: { @@ -514,19 +513,10 @@ window.app = Vue.createApp({ this.getDeposits() ]) - // Calculate total DCA balance - this.calculateTotalDcaBalance() - // Legacy data loading await this.getMyExtensions() }, - watch: { - deposits() { - this.calculateTotalDcaBalance() - } - }, - computed: { clientOptions() { return this.dcaClients.map(client => ({ @@ -535,8 +525,8 @@ window.app = Vue.createApp({ })) }, - calculateTotalDcaBalance() { - this.totalDcaBalance = this.deposits + totalDcaBalance() { + return this.deposits .filter(d => d.status === 'confirmed') .reduce((total, deposit) => total + deposit.amount, 0) }