add fiat balance to wallet (#2157)
also fixed payments table fiat denomination for consistency
This commit is contained in:
@@ -241,6 +241,7 @@ new Vue({
|
||||
location: window.location
|
||||
},
|
||||
balance: 0,
|
||||
fiatBalance: 0,
|
||||
credit: 0,
|
||||
update: {
|
||||
name: null,
|
||||
@@ -256,6 +257,14 @@ new Vue({
|
||||
return LNbits.utils.formatSat(this.balance || this.g.wallet.sat)
|
||||
}
|
||||
},
|
||||
formattedFiatBalance() {
|
||||
if (this.fiatBalance) {
|
||||
return LNbits.utils.formatCurrency(
|
||||
this.fiatBalance.toFixed(2),
|
||||
this.g.wallet.currency
|
||||
)
|
||||
}
|
||||
},
|
||||
filteredPayments: function () {
|
||||
var q = this.paymentsTable.filter
|
||||
if (!q || q === '') return this.payments
|
||||
@@ -797,6 +806,24 @@ new Vue({
|
||||
this.balance
|
||||
])
|
||||
})
|
||||
if (this.g.wallet.currency) {
|
||||
this.updateFiatBalance()
|
||||
}
|
||||
},
|
||||
updateFiatBalance() {
|
||||
if (!this.g.wallet.currency) return 0
|
||||
LNbits.api
|
||||
.request('POST', `/api/v1/conversion`, null, {
|
||||
amount: this.balance || this.g.wallet.sat,
|
||||
to: this.g.wallet.currency
|
||||
})
|
||||
.then(response => {
|
||||
this.fiatBalance = response.data[this.g.wallet.currency]
|
||||
})
|
||||
.catch(e => console.error(e))
|
||||
},
|
||||
formatFiat(currency, amount) {
|
||||
return LNbits.utils.formatCurrency(amount, currency)
|
||||
},
|
||||
exportCSV: function () {
|
||||
// status is important for export but it is not in paymentsTable
|
||||
|
||||
Reference in New Issue
Block a user