feat: link order to DMs

This commit is contained in:
Vlad Stan 2023-03-17 10:51:20 +02:00
parent b45927a15d
commit d7d7869b0e
11 changed files with 32 additions and 23 deletions

View file

@ -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) {

View file

@ -44,7 +44,12 @@
</q-td>
<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 key="time" :props="props"> {{formatDate(props.row.time)}} </q-td>
</q-tr>

View file

@ -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 () {

View file

@ -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',

View file

@ -190,6 +190,7 @@
:adminkey="adminkey"
:inkey="inkey"
:stall-id="stallId"
@customer-selected="customerSelectedForOrder"
></order-list>
</div>
</q-tab-panel>

View file

@ -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 () {

View file

@ -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>

View file

@ -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 () {

View file

@ -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 () {