Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix currency errors on v1 #109

Merged
merged 4 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions static/js/tpos.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ window.app = Vue.createApp({
},
monochrome: this.$q.localStorage.getItem('lnbits.tpos.color') || false,
showPoS: true,
cartDrawer: this.$q.screen.width > 1200,
cartDrawer: this.$q.screen.gt.md,
searchTerm: '',
categoryFilter: '',
cart: new Map(),
Expand All @@ -101,6 +101,7 @@ window.app = Vue.createApp({
computed: {
amount: function () {
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)
Expand Down Expand Up @@ -179,7 +180,7 @@ window.app = Vue.createApp({
return items
},
drawerWidth() {
return this.$q.screen.width < 500 ? 375 : 450
return this.$q.screen.lt.sm ? 375 : 450
},
formattedCartTax() {
return this.formatAmount(this.cartTax, this.currency)
Expand Down Expand Up @@ -335,7 +336,7 @@ window.app = Vue.createApp({
dialog.show = false
this.atmPin = null
this.atmToken = ''
this.complete.show = true
this.showComplete()
this.atmMode = false
this.connectionWithdraw.close()
}
Expand Down Expand Up @@ -476,7 +477,7 @@ window.app = Vue.createApp({
dialog.show = false
this.clearCart()

this.complete.show = true
this.showComplete()
}
})
}, 3000)
Expand Down Expand Up @@ -619,11 +620,13 @@ window.app = Vue.createApp({
getRates() {
if (this.currency == 'sats') {
this.exchangeRate = 1
Quasar.Loading.hide()
} else {
LNbits.api
.request('GET', `/tpos/api/v1/rate/${this.currency}`)
.then(response => {
this.exchangeRate = response.data.rate
Quasar.Loading.hide()
})
.catch(e => console.error(e))
}
Expand Down Expand Up @@ -689,9 +692,16 @@ window.app = Vue.createApp({
} else {
return LNbits.utils.formatCurrency(Number(amount).toFixed(2), currency)
}
},
showComplete() {
this.complete.show = true
if (this.$q.screen.lt.lg && this.cartDrawer) {
this.cartDrawer = false
}
}
},
created() {
Quasar.Loading.show()
this.tposId = tpos.id
this.currency = tpos.currency
this.atmPremium = tpos.withdraw_premium / 100
Expand Down
2 changes: 1 addition & 1 deletion templates/tpos/tpos.html
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ <h5>
show-if-above
bordered
:width="drawerWidth"
:breakpoint="1200"
:breakpoint="1024"
>
<div class="row full-width q-pa-md">
<div class="absolute-top-right q-pa-md">
Expand Down
3 changes: 2 additions & 1 deletion views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from http import HTTPStatus
from typing import Optional

from fastapi import APIRouter, Depends, HTTPException, Request
from lnbits.core.models import User
Expand Down Expand Up @@ -31,7 +32,7 @@ async def tpos(request: Request, tpos_id):
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND, detail="TPoS does not exist."
)
withdraw_pin_open = 0
withdraw_pin_open: Optional[int] = 0
if tpos.withdraw_pin_disabled:
withdraw_pin_open = tpos.withdraw_pin

Expand Down