Skip to content

Commit

Permalink
fix: exchange rate now is a tuple/list
Browse files Browse the repository at this point in the history
  • Loading branch information
talvasconcelos committed Dec 18, 2024
1 parent f8648fd commit e82d69e
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions static/js/tpos.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,42 +103,42 @@ window.app = Vue.createApp({
}
},
computed: {
amount: function () {
amount() {
if (!this.stack.length) return 0.0
if (this.currency == 'sats') return Number(this.stack.join(''))
return (
this.stack.reduce((acc, dig) => acc * 10 + dig, 0) *
(this.currency == 'sats' ? 1 : 0.01)
)
},
amountFormatted: function () {
amountFormatted() {
return this.formatAmount(this.amount, this.currency)
},
totalFormatted() {
return this.formatAmount(this.total, this.currency)
},
amountWithTipFormatted: function () {
amountWithTipFormatted() {
return this.formatAmount(this.amount + this.tipAmount, this.currency)
},
sat: function () {
sat() {
if (!this.exchangeRate) return 0
return Math.ceil(this.amount * this.exchangeRate)
},
totalSat: function () {
totalSat() {
if (!this.exchangeRate) return 0
return Math.ceil(this.total * this.exchangeRate)
},
tipAmountSat: function () {
tipAmountSat() {
if (!this.exchangeRate) return 0
return Math.ceil(this.tipAmount * this.exchangeRate)
},
tipAmountFormatted: function () {
tipAmountFormatted() {
return LNbits.utils.formatSat(this.tipAmountSat)
},
fsat: function () {
fsat() {
return LNbits.utils.formatSat(this.sat)
},
totalfsat: function () {
totalfsat() {
return LNbits.utils.formatSat(this.totalSat)
},
roundToSugestion() {
Expand Down Expand Up @@ -658,8 +658,7 @@ window.app = Vue.createApp({
LNbits.api
.request('GET', `/tpos/api/v1/rate/${this.currency}`)
.then(response => {
this.exchangeRate = response.data.rate
console.log(this.exchangeRate)
this.exchangeRate = response.data.rate[0]
Quasar.Loading.hide()
})
.catch(e => console.error(e))
Expand Down

0 comments on commit e82d69e

Please sign in to comment.