Refactor total DCA balance calculation: remove redundant state variable and update computed property to directly calculate balance from deposits.
This commit is contained in:
parent
46b7a1450d
commit
c9f7140d95
1 changed files with 2 additions and 12 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue