feat: show order details for customer

This commit is contained in:
Vlad Stan 2023-07-04 09:34:44 +03:00
parent e6f2750272
commit 1a82fc030a
6 changed files with 27 additions and 13 deletions

View file

@ -45,17 +45,19 @@
<div v-if="dm.isJson">
<div v-if="dm.message.type === 0">
<strong>New order:</strong>
<span v-text="dm.message.id"></span>
</div>
<div v-else-if="dm.message.type === 1">
<strong>Invoice sent for order: </strong>
<span v-text="dm.message.id"></span>
</div>
<div v-else-if="dm.message.type === 2">
<q-badge v-if="dm.message.paid" color="green">Paid </q-badge>
<q-badge v-if="dm.message.shipped" color="green">Shipped </q-badge>
<span v-text="dm.message.message"></span><br>
<span v-text="dm.message.id"></span>
</div>
<div>
<span v-text="dm.message.id" @click="showOrderDetails(dm.message.id)"
class="cursor-pointer"></span>
</div>
<q-badge @click="showMessageRawData(index)" class="cursor-pointer">...</q-badge>

View file

@ -136,6 +136,9 @@ async function directMessages(path) {
}
this.getCustomersDebounced()
},
showOrderDetails: function (orderId) {
this.$emit('order-selected', orderId)
},
showClientOrders: function () {
this.$emit('customer-selected', this.activePublicKey)
},

View file

@ -170,7 +170,6 @@ async function orderList(path) {
this.inkey
)
this.orders = data.map(s => ({ ...s, expanded: false }))
console.log("### this.orders", this.orders)
} catch (error) {
LNbits.utils.notifyApiError(error)
}
@ -238,7 +237,13 @@ async function orderList(path) {
this.orders.unshift(order)
}
},
orderSelected: async function (orderId) {
const order = await this.getOrder(orderId)
if (!order) return
order.expanded = true
order.isNew = false
this.orders = [order]
},
showShipOrderDialog: function (order) {
this.selectedOrder = order
this.shippingMessage = order.shipped
@ -274,7 +279,7 @@ async function orderList(path) {
)}`
return label
},
orderPaid: function(orderId) {
orderPaid: function (orderId) {
const order = this.orders.find(o => o.id === orderId)
if (order) {
order.paid = true

View file

@ -152,6 +152,9 @@ const merchant = async () => {
filterOrdersForCustomer: function (customerPubkey) {
this.orderPubkey = customerPubkey
},
showOrderDetails: async function (orderId) {
await this.$refs.orderListRef.orderSelected(orderId)
},
waitForNotifications: async function () {
if (!this.merchant) return
try {

View file

@ -179,6 +179,7 @@
:active-chat-customer="activeChatCustomer"
:merchant-id="merchant.id"
@customer-selected="filterOrdersForCustomer"
@order-selected="showOrderDetails"
>
</direct-messages>
</div>

View file

@ -5,8 +5,8 @@ from typing import List, Optional
from fastapi import Depends
from fastapi.exceptions import HTTPException
from loguru import logger
from lnbits.core.services import websocketUpdater
from lnbits.core.services import websocketUpdater
from lnbits.decorators import (
WalletTypeInfo,
check_admin,