fix products price in fiat

This commit is contained in:
Tiago Vasconcelos 2022-12-29 12:02:03 +00:00
parent 11b015e516
commit 690ef74313
3 changed files with 29 additions and 4 deletions

View File

@ -94,7 +94,10 @@
</q-item-section>
<q-item-section side>
<span> {{p.price}} sats</span>
<span v-if="stall.currency != 'sat'"
>{{ getAmountFormated(p.price) }}</span
>
<span v-else> {{p.price}} sats</span>
</q-item-section>
</q-item>
{% endraw %}
@ -273,6 +276,12 @@
}
return obj
}
const mapProductsItems = obj => {
obj.price = (obj.price / 100).toFixed(2)
return obj
}
Vue.component(VueQrcode.name, VueQrcode)
const nostr = window.NostrTools
new Vue({
@ -314,6 +323,9 @@
}
},
methods: {
getAmountFormated(amount) {
return LNbits.utils.formatCurrency(amount, this.stall.currency)
},
clearMessage() {
this.newMessage = ''
this.$refs.newMessage.focus()
@ -471,6 +483,10 @@
price: product.price
}
})
console.log(this.stall)
if (this.stall.currency != 'sat') {
this.products = this.products.map(mapProductsItems)
}
let data = this.$q.localStorage.getItem(`lnbits.shop.data`) || false

View File

@ -284,6 +284,11 @@
</div>
{% endblock %} {% block scripts %}
<script>
const mapProductsItems = obj => {
obj.price = (obj.price / 100).toFixed(2)
return obj
}
Vue.component(VueQrcode.name, VueQrcode)
new Vue({
el: '#vue',
@ -333,8 +338,8 @@
let zoneCost = this.stall.zones.find(
z => z.value == this.checkoutDialog.data.shippingzone
)
return this.cart.total + zoneCost.cost
console.log(+this.cart.total, zoneCost.cost)
return +this.cart.total + zoneCost.cost
}
},
methods: {
@ -350,7 +355,7 @@
}
},
getAmountFormated(amount) {
return LNbits.utils.formatCurrency(amount.toFixed(2), this.unit)
return LNbits.utils.formatCurrency(amount, this.unit)
},
async getRates() {
if (this.unit == 'sat') return
@ -492,6 +497,9 @@
this.stall = JSON.parse('{{ stall | tojson }}')
this.products = JSON.parse('{{ products | tojson }}')
this.unit = this.stall.currency
if (this.unit != 'sat') {
this.products = this.products.map(mapProductsItems)
}
await this.getRates()
setInterval(this.getRates, 300000)
}

View File

@ -122,6 +122,7 @@ async def order_chat(
"name": stall.name,
"publickey": stall.publickey,
"wallet": stall.wallet,
"currency": stall.currency,
},
"publickey": keys.split(",")[0] if keys else None,
"privatekey": keys.split(",")[1] if keys else None,