Fix subscription errors (#81)

* pref: merge filters in one

* chore: load nit

* feat: restore individual order
This commit is contained in:
Vlad Stan 2023-09-12 15:03:37 +03:00 committed by GitHub
parent a3299b63c4
commit 889152a80b
8 changed files with 138 additions and 66 deletions

View file

@ -57,7 +57,7 @@
<div>
<span v-text="dm.message.message"></span>
<q-badge color="orange">
<span v-text="dm.message.id" @click="showOrderDetails(dm.message.id)" class="cursor-pointer"></span>
<span v-text="dm.message.id" @click="showOrderDetails(dm.message.id, dm.event_id)" class="cursor-pointer"></span>
</q-badge>
</div>
<q-badge @click="showMessageRawData(index)" class="cursor-pointer">...</q-badge>

View file

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

View file

@ -189,12 +189,33 @@ async function orderList(path) {
LNbits.utils.notifyApiError(error)
}
},
restoreOrder: async function (eventId) {
console.log('### restoreOrder', eventId)
try {
this.search.restoring = true
const {data} = await LNbits.api.request(
'PUT',
`/nostrmarket/api/v1/order/restore/${eventId}`,
this.adminkey
)
await this.getOrders()
this.$q.notify({
type: 'positive',
message: 'Order restored!'
})
return data
} catch (error) {
LNbits.utils.notifyApiError(error)
} finally {
this.search.restoring = false
}
},
restoreOrders: async function () {
try {
this.search.restoring = true
await LNbits.api.request(
'PUT',
`/nostrmarket/api/v1/order/restore`,
`/nostrmarket/api/v1/orders/restore`,
this.adminkey
)
await this.getOrders()
@ -269,9 +290,25 @@ async function orderList(path) {
}
},
orderSelected: async function (orderId) {
orderSelected: async function (orderId, eventId) {
const order = await this.getOrder(orderId)
if (!order) return
if (!order) {
LNbits.utils
.confirmDialog(
"Order could not be found. Do you want to restore it from this direct message?"
)
.onOk(async () => {
const restoredOrder = await this.restoreOrder(eventId)
console.log('### restoredOrder', restoredOrder)
if (restoredOrder) {
restoredOrder.expanded = true
restoredOrder.isNew = false
this.orders = [restoredOrder]
}
})
return
}
order.expanded = true
order.isNew = false
this.orders = [order]

View file

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