Skip to content

Commit

Permalink
Merge branch 'main' into atm_pin_toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
arcbtc committed Feb 11, 2024
2 parents 10e857d + 30dfae3 commit 83775c2
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 29 deletions.
16 changes: 12 additions & 4 deletions templates/tpos/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ <h6 class="text-subtitle1 q-my-none">
return {
tposs: [],
currencyOptions: [
'sats',
'USD',
'EUR',
'GBP',
Expand Down Expand Up @@ -938,10 +939,7 @@ <h6 class="text-subtitle1 q-my-none">
id: tpos.wallet
})
data.forEach(item => {
item.formattedPrice = LNbits.utils.formatCurrency(
Number(item.price).toFixed(2),
tpos.currency
)
item.formattedPrice = this.formatAmount(item.price, tpos.currency)
})
this.fileDataDialog.data = data
this.fileDataDialog.count = data.length
Expand All @@ -958,6 +956,16 @@ <h6 class="text-subtitle1 q-my-none">
openUrlDialog(id) {
this.urlDialog.data = _.findWhere(this.tposs, { id })
this.urlDialog.show = true
},
formatAmount: function (amount, currency) {
if (currency == 'sats') {
return LNbits.utils.formatSat(amount) + ' sat'
} else {
return LNbits.utils.formatCurrency(
Number(amount).toFixed(2),
currency
)
}
}
},
created: function () {
Expand Down
71 changes: 46 additions & 25 deletions templates/tpos/tpos.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,16 @@
<div class="row justify-center full-width">
<div class="col-12 col-sm-8 col-md-6 col-lg-4 text-center">
<h3 class="q-mb-md">${ amountFormatted }</h3>
<h5 class="q-mt-none q-mb-sm">${ fsat }<small> sat</small></h5>
<h5 v-show="!denomIsSats" class="q-mt-none q-mb-sm">
${ fsat }<small> sat</small>
</h5>
<div v-if="total > 0.0">
<h5>
<i>Total: ${totalFormatted}<br />${totalfsat} sat</i>
<i
>Total: ${totalFormatted}<span v-if="!denomIsSats"
><br />${totalfsat} sat</span
></i
>
</h5>
</div>
</div>
Expand Down Expand Up @@ -220,7 +226,9 @@ <h5>
<div class="row full-width q-pa-md">
<div class="col-12 text-center">
<h3 class="q-mb-md">${totalFormatted}</h3>
<h5 class="q-mt-none q-mb-sm">${totalfsat}<small> sat</small></h5>
<h5 v-show="!denomIsSats" class="q-mt-none q-mb-sm">
${totalfsat}<small> sat</small>
</h5>
</div>
<div class="col-12">
<table class="table full-width">
Expand Down Expand Up @@ -756,28 +764,26 @@ <h5 class="q-mt-none q-mb-sm">
cartDrawer: this.$q.screen.width > 1200,
searchTerm: '',
categoryFilter: '',
cart: new Map()
cart: new Map(),
denomIsSats: '{{ tpos.currency }}' == 'sats'
}
},
computed: {
amount: function () {
if (!this.stack.length) return 0.0
return this.stack.reduce((acc, dig) => acc * 10 + dig, 0) * 0.01
return (
this.stack.reduce((acc, dig) => acc * 10 + dig, 0) *
(this.currency == 'sats' ? 1 : 0.01)
)
},
amountFormatted: function () {
return LNbits.utils.formatCurrency(
this.amount.toFixed(2),
this.currency
)
return this.formatAmount(this.amount, this.currency)
},
totalFormatted() {
return LNbits.utils.formatCurrency(this.total.toFixed(2), this.currency)
return this.formatAmount(this.total, this.currency)
},
amountWithTipFormatted: function () {
return LNbits.utils.formatCurrency(
(this.amount + this.tipAmount).toFixed(2),
this.currency
)
return this.formatAmount(this.amount + this.tipAmount, this.currency)
},
sat: function () {
if (!this.exchangeRate) return 0
Expand Down Expand Up @@ -1006,7 +1012,11 @@ <h5 class="q-mt-none q-mb-sm">
},
submitForm: function () {
if (this.total != 0.0) {
this.stack = Array.from(String(Math.ceil(this.total * 100)), Number)
if (this.currency == 'sats') {
this.stack = Array.from(String(Math.ceil(this.total), Number))
} else {
this.stack = Array.from(String(Math.ceil(this.total * 100)), Number)
}
}
if (!this.exchangeRate || this.exchangeRate == 0 || this.sat == 0) {
this.$q.notify({
Expand Down Expand Up @@ -1235,12 +1245,16 @@ <h5 class="q-mt-none q-mb-sm">
})
},
getRates() {
LNbits.api
.request('GET', `/tpos/api/v1/rate/${this.currency}`)
.then(response => {
this.exchangeRate = response.data.rate
})
.catch(e => console.error(e))
if (this.currency == 'sats') {
this.exchangeRate = 1
} else {
LNbits.api
.request('GET', `/tpos/api/v1/rate/${this.currency}`)
.then(response => {
this.exchangeRate = response.data.rate
})
.catch(e => console.error(e))
}
},
getLastPayments() {
return axios
Expand Down Expand Up @@ -1296,6 +1310,16 @@ <h5 class="q-mt-none q-mb-sm">
} else {
this.categoryFilter = category == 'All' ? '' : category
}
},
formatAmount: function (amount, currency) {
if (currency == 'sats') {
return LNbits.utils.formatSat(amount) + ' sat'
} else {
return LNbits.utils.formatCurrency(
Number(amount).toFixed(2),
currency
)
}
}
},
created: function () {
Expand All @@ -1313,10 +1337,7 @@ <h5 class="q-mt-none q-mb-sm">

this.items = JSON.parse(`{{ tpos.items | safe }}`)
this.items.forEach((item, id) => {
item.formattedPrice = LNbits.utils.formatCurrency(
item.price,
this.currency
)
item.formattedPrice = this.formatAmount(item.price, this.currency)
item.id = id
return item
})
Expand Down

0 comments on commit 83775c2

Please sign in to comment.