fix: shipping cost; update UI on new order

This commit is contained in:
Vlad Stan 2023-04-03 11:57:55 +03:00
parent f80a75e90c
commit 547c477ce6
11 changed files with 57 additions and 23 deletions

View file

@ -375,8 +375,9 @@ async function customerStall(path) {
this.qrCodeDialog.data.message = json.message
return cb()
}
let payment_request = json.payment_options.find(o => o.type == 'ln')
.link
let payment_request = json.payment_options.find(
o => o.type == 'ln'
).link
if (!payment_request) return
this.loading = false
this.qrCodeDialog.data.payment_request = payment_request

View file

@ -83,6 +83,13 @@ async function directMessages(path) {
LNbits.utils.notifyApiError(error)
}
},
handleNewMessage: async function (data) {
if (data.customerPubkey === this.activePublicKey) {
await this.getDirectMessages(this.activePublicKey)
} else {
await this.getCustomers()
}
},
showClientOrders: function () {
this.$emit('customer-selected', this.activePublicKey)
},

View file

@ -141,8 +141,11 @@
</div>
<div class="col-1"></div>
</div>
<div v-if="props.row.extra.currency !== 'sat'" class="row items-center no-wrap q-mb-md q-mt-md">
<div class="col-3 q-pr-lg">Exchange Rate:</div>
<div
v-if="props.row.extra.currency !== 'sat'"
class="row items-center no-wrap q-mb-md q-mt-md"
>
<div class="col-3 q-pr-lg">Exchange Rate (1 BTC):</div>
<div class="col-6 col-sm-8 q-pr-lg">
<q-input
filled

View file

@ -64,13 +64,13 @@ async function orderList(path) {
{
name: 'total',
align: 'left',
label: 'Total',
label: 'Total Sats',
field: 'total'
},
{
name: 'fiat',
align: 'left',
label: 'Fiat',
label: 'Total Fiat',
field: 'fiat'
},
{
@ -136,7 +136,6 @@ async function orderList(path) {
},
orderTotal: function (order) {
return order.items.reduce((t, item) => {
console.log('### t, o', t, item)
product = order.extra.products.find(p => p.id === item.product_id)
return t + item.quantity * product.price
}, 0)

View file

@ -113,9 +113,7 @@ const merchant = async () => {
const port = location.port ? `:${location.port}` : ''
const wsUrl = `${scheme}://${document.domain}${port}/api/v1/ws/${this.merchant.id}`
const wsConnection = new WebSocket(wsUrl)
console.log('### waiting for events')
wsConnection.onmessage = async e => {
console.log('### e', e)
const data = JSON.parse(e.data)
if (data.type === 'new-order') {
this.$q.notify({
@ -126,6 +124,7 @@ const merchant = async () => {
await this.$refs.orderListRef.addOrder(data)
} else if (data.type === 'new-customer') {
} else if (data.type === 'new-direct-message') {
await this.$refs.directMessagesRef.handleNewMessage(data)
}
}
} catch (error) {