Refactor total DCA balance calculation: remove redundant state variable and update computed property to directly calculate balance from deposits.

This commit is contained in:
padreug 2025-06-18 10:08:44 +02:00
parent 46b7a1450d
commit c9f7140d95

View file

@ -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)
}