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
|
// DCA Admin Data
|
||||||
dcaClients: [],
|
dcaClients: [],
|
||||||
deposits: [],
|
deposits: [],
|
||||||
totalDcaBalance: 0,
|
|
||||||
|
|
||||||
// Table configurations
|
// Table configurations
|
||||||
clientsTable: {
|
clientsTable: {
|
||||||
|
|
@ -514,19 +513,10 @@ window.app = Vue.createApp({
|
||||||
this.getDeposits()
|
this.getDeposits()
|
||||||
])
|
])
|
||||||
|
|
||||||
// Calculate total DCA balance
|
|
||||||
this.calculateTotalDcaBalance()
|
|
||||||
|
|
||||||
// Legacy data loading
|
// Legacy data loading
|
||||||
await this.getMyExtensions()
|
await this.getMyExtensions()
|
||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
|
||||||
deposits() {
|
|
||||||
this.calculateTotalDcaBalance()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
clientOptions() {
|
clientOptions() {
|
||||||
return this.dcaClients.map(client => ({
|
return this.dcaClients.map(client => ({
|
||||||
|
|
@ -535,8 +525,8 @@ window.app = Vue.createApp({
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
|
|
||||||
calculateTotalDcaBalance() {
|
totalDcaBalance() {
|
||||||
this.totalDcaBalance = this.deposits
|
return this.deposits
|
||||||
.filter(d => d.status === 'confirmed')
|
.filter(d => d.status === 'confirmed')
|
||||||
.reduce((total, deposit) => total + deposit.amount, 0)
|
.reduce((total, deposit) => total + deposit.amount, 0)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue