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