feat: link order to DMs
This commit is contained in:
parent
b45927a15d
commit
d7d7869b0e
11 changed files with 32 additions and 23 deletions
|
|
@ -2,13 +2,17 @@ async function directMessages(path) {
|
|||
const template = await loadTemplateAsync(path)
|
||||
Vue.component('direct-messages', {
|
||||
name: 'direct-messages',
|
||||
props: ['adminkey', 'inkey'],
|
||||
props: ['active-public-key', 'adminkey', 'inkey'],
|
||||
template,
|
||||
|
||||
watch: {
|
||||
activePublicKey: async function (n) {
|
||||
await this.getDirectMessages(n)
|
||||
}
|
||||
},
|
||||
data: function () {
|
||||
return {
|
||||
customersPublicKeys: [],
|
||||
activePublicKey: '',
|
||||
messages: [],
|
||||
newMessage: ''
|
||||
}
|
||||
|
|
@ -44,7 +48,6 @@ async function directMessages(path) {
|
|||
this.inkey
|
||||
)
|
||||
this.customersPublicKeys = data
|
||||
console.log('### this.customersPublicKeys', this.customersPublicKeys)
|
||||
} catch (error) {
|
||||
LNbits.utils.notifyApiError(error)
|
||||
}
|
||||
|
|
@ -61,7 +64,6 @@ async function directMessages(path) {
|
|||
}
|
||||
)
|
||||
this.messages = this.messages.concat([data])
|
||||
console.log('### this.messages', this.messages)
|
||||
this.newMessage = ''
|
||||
this.focusOnChatBox(this.messages.length - 1)
|
||||
} catch (error) {
|
||||
|
|
@ -69,7 +71,6 @@ async function directMessages(path) {
|
|||
}
|
||||
},
|
||||
selectActiveCustomer: async function () {
|
||||
console.log('### selectActiveCustomer', this.activePublicKey)
|
||||
await this.getDirectMessages(this.activePublicKey)
|
||||
},
|
||||
focusOnChatBox: function (index) {
|
||||
|
|
|
|||
|
|
@ -44,7 +44,12 @@
|
|||
</q-td>
|
||||
|
||||
<q-td key="public_key" :props="props">
|
||||
<span
|
||||
@click="customerSelected(props.row.public_key)"
|
||||
class="cursor-pointer"
|
||||
>
|
||||
{{toShortId(props.row.public_key)}}
|
||||
</span>
|
||||
</q-td>
|
||||
<q-td key="time" :props="props"> {{formatDate(props.row.time)}} </q-td>
|
||||
</q-tr>
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ async function orderList(path) {
|
|||
field: 'shipped'
|
||||
},
|
||||
{
|
||||
name: 'pubkey',
|
||||
name: 'public_key',
|
||||
align: 'left',
|
||||
label: 'Customer',
|
||||
field: 'pubkey'
|
||||
|
|
@ -91,13 +91,11 @@ 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)
|
||||
}
|
||||
},
|
||||
updateOrderShipped: async function () {
|
||||
console.log('### order', this.selectedOrder)
|
||||
this.selectedOrder.shipped = !this.selectedOrder.shipped
|
||||
try {
|
||||
await LNbits.api.request(
|
||||
|
|
@ -128,6 +126,9 @@ async function orderList(path) {
|
|||
// do not change the status yet
|
||||
this.selectedOrder.shipped = !order.shipped
|
||||
this.showShipDialog = true
|
||||
},
|
||||
customerSelected: function (customerPubkey) {
|
||||
this.$emit('customer-selected', customerPubkey)
|
||||
}
|
||||
},
|
||||
created: async function () {
|
||||
|
|
|
|||
|
|
@ -102,13 +102,11 @@ async function shippingZones(path) {
|
|||
this.inkey
|
||||
)
|
||||
this.zones = data
|
||||
console.log('### data', data)
|
||||
} catch (error) {
|
||||
LNbits.utils.notifyApiError(error)
|
||||
}
|
||||
},
|
||||
sendZoneFormData: async function () {
|
||||
console.log('### data', this.zoneDialog.data)
|
||||
this.zoneDialog.showDialog = false
|
||||
if (this.zoneDialog.data.id) {
|
||||
await this.updateShippingZone(this.zoneDialog.data)
|
||||
|
|
@ -118,7 +116,6 @@ async function shippingZones(path) {
|
|||
await this.getZones()
|
||||
},
|
||||
createShippingZone: async function (newZone) {
|
||||
console.log('### newZone', newZone)
|
||||
try {
|
||||
await LNbits.api.request(
|
||||
'POST',
|
||||
|
|
|
|||
|
|
@ -190,6 +190,7 @@
|
|||
:adminkey="adminkey"
|
||||
:inkey="inkey"
|
||||
:stall-id="stallId"
|
||||
@customer-selected="customerSelectedForOrder"
|
||||
></order-list>
|
||||
</div>
|
||||
</q-tab-panel>
|
||||
|
|
|
|||
|
|
@ -119,8 +119,6 @@ async function stallDetails(path) {
|
|||
this.inkey
|
||||
)
|
||||
this.stall = this.mapStall(data)
|
||||
|
||||
console.log('### this.stall', this.stall)
|
||||
} catch (error) {
|
||||
LNbits.utils.notifyApiError(error)
|
||||
}
|
||||
|
|
@ -197,8 +195,6 @@ async function stallDetails(path) {
|
|||
this.inkey
|
||||
)
|
||||
this.products = data
|
||||
|
||||
console.log('### this.products', this.products)
|
||||
} catch (error) {
|
||||
LNbits.utils.notifyApiError(error)
|
||||
}
|
||||
|
|
@ -305,6 +301,9 @@ async function stallDetails(path) {
|
|||
}
|
||||
}
|
||||
this.productDialog.showDialog = true
|
||||
},
|
||||
customerSelectedForOrder: function (customerPubkey) {
|
||||
this.$emit('customer-selected-for-order', customerPubkey)
|
||||
}
|
||||
},
|
||||
created: async function () {
|
||||
|
|
|
|||
|
|
@ -46,9 +46,7 @@
|
|||
</q-td>
|
||||
|
||||
<q-td key="id" :props="props">
|
||||
<a style="color: unset" :href="props.row.id" target="_blank">
|
||||
{{props.row.name}}</a
|
||||
>
|
||||
{{props.row.name}}
|
||||
</q-td>
|
||||
<q-td key="currency" :props="props"> {{props.row.currency}} </q-td>
|
||||
<q-td key="description" :props="props">
|
||||
|
|
@ -74,6 +72,7 @@
|
|||
:currencies="currencies"
|
||||
@stall-deleted="handleStallDeleted"
|
||||
@stall-updated="handleStallUpdated"
|
||||
@customer-selected-for-order="customerSelectedForOrder"
|
||||
></stall-details>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -170,6 +170,9 @@ async function stallList(path) {
|
|||
shippingZones: []
|
||||
}
|
||||
this.stallDialog.show = true
|
||||
},
|
||||
customerSelectedForOrder: function (customerPubkey) {
|
||||
this.$emit('customer-selected-for-order', customerPubkey)
|
||||
}
|
||||
},
|
||||
created: async function () {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ const merchant = async () => {
|
|||
return {
|
||||
merchant: {},
|
||||
shippingZones: [],
|
||||
activeChatCustomer: '',
|
||||
showKeys: false,
|
||||
importKeyDialog: {
|
||||
show: false,
|
||||
|
|
@ -92,6 +93,9 @@ const merchant = async () => {
|
|||
} catch (error) {
|
||||
LNbits.utils.notifyApiError(error)
|
||||
}
|
||||
},
|
||||
customerSelectedForOrder: function (customerPubkey) {
|
||||
this.activeChatCustomer = customerPubkey
|
||||
}
|
||||
},
|
||||
created: async function () {
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
:adminkey="g.user.wallets[0].adminkey"
|
||||
:inkey="g.user.wallets[0].inkey"
|
||||
:wallet-options="g.user.walletOptions"
|
||||
@customer-selected-for-order="customerSelectedForOrder"
|
||||
></stall-list>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
|
|
@ -114,6 +115,7 @@
|
|||
</div>
|
||||
<div v-if="merchant && merchant.id" class="col-12">
|
||||
<direct-messages
|
||||
:active-public-key="activeChatCustomer"
|
||||
:inkey="g.user.wallets[0].inkey"
|
||||
:adminkey="g.user.wallets[0].adminkey"
|
||||
>
|
||||
|
|
|
|||
|
|
@ -645,14 +645,11 @@ async def api_update_order_status(
|
|||
try:
|
||||
assert data.shipped != None, "Shipped value is required for order"
|
||||
merchant = await get_merchant_for_user(wallet.wallet.user)
|
||||
assert merchant, "Merchant cannot be found"
|
||||
assert merchant, "Merchant cannot be found for order {data.id}"
|
||||
|
||||
order = await update_order_shipped_status(merchant.id, data.id, data.shipped)
|
||||
assert order, "Cannot find updated order"
|
||||
|
||||
merchant = await get_merchant_for_user(merchant.id)
|
||||
assert merchant, f"Merchant cannot be found for order {data.id}"
|
||||
|
||||
data.paid = order.paid
|
||||
dm_content = json.dumps(data.dict(), separators=(",", ":"), ensure_ascii=False)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue