Skip to content

Commit

Permalink
fix currency errors on v1 (#109)
Browse files Browse the repository at this point in the history
* fix currency errors on v1
* fix: close cart drawer on completion
* chore: fix lint
* fix: use quasar screen api

---------

Co-authored-by: Vlad Stan <[email protected]>
  • Loading branch information
talvasconcelos and motorina0 authored Nov 26, 2024
1 parent 4a26f33 commit d42e1d1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
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

0 comments on commit d42e1d1

Please sign in to comment.