feat: orders UI
This commit is contained in:
parent
6d921d7559
commit
edef69c92c
2 changed files with 68 additions and 18 deletions
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
<q-separator />
|
||||
|
||||
<q-card-section horizontal>
|
||||
<q-card-section>
|
||||
|
||||
<q-card-section class="col-12">
|
||||
<q-list class="q-mt-md">
|
||||
|
|
@ -40,8 +40,8 @@
|
|||
<template v-slot:header>
|
||||
<q-item-section class="q-mt-sm">
|
||||
<q-item-label><strong> <span v-text="order.stallName"></span> </strong>
|
||||
<q-badge @click="showInvoice(order)"
|
||||
v-if="order.invoice?.human_readable_part?.amount" color="orange" class="q-ml-lg">
|
||||
<q-badge @click="showInvoice(order)" v-if="order.invoice?.human_readable_part?.amount"
|
||||
color="orange" class="q-ml-lg">
|
||||
<span v-text="formatCurrency(order.invoice?.human_readable_part?.amount / 1000, 'sat')"></span>
|
||||
</q-badge></q-item-label>
|
||||
|
||||
|
|
@ -70,12 +70,52 @@
|
|||
</q-item-label>
|
||||
</q-item-section>
|
||||
</template>
|
||||
<q-card-section class="q-pa-none">
|
||||
<q-separator></q-separator>
|
||||
<span v-text="order.invoice?.human_readable_part?.amount"></span>
|
||||
<q-separator></q-separator>
|
||||
<q-card-section horizontal>
|
||||
|
||||
<q-card-section class="col-7">
|
||||
<q-item-section class="q-mt-sm">
|
||||
<q-item-label> <strong>Products</strong></q-item-label>
|
||||
</q-item-section>
|
||||
|
||||
<q-item v-for="product in order.products" :key="product.id">
|
||||
<q-item-section avatar>
|
||||
<q-avatar>
|
||||
<img v-if="product.images[0] || product.image" :src="product.images[0] || product.image" />
|
||||
<img v-else src="/nostrmarket/static/images/placeholder.png" />
|
||||
</q-avatar>
|
||||
</q-item-section>
|
||||
<q-item-section class="q-mt-sm">
|
||||
<q-item-label></q-item-label>
|
||||
<q-item-label>
|
||||
<strong>{{ product.orderedQuantity}} x {{ product.name}} </strong></q-item-label>
|
||||
<q-item-label>
|
||||
<div class="text-caption text-grey ellipsis-2-lines">
|
||||
<p>{{ product.description }}</p>
|
||||
</div>
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
|
||||
</q-card-section>
|
||||
<q-separator vertical />
|
||||
<q-card-section>
|
||||
<q-item-section class="q-mt-sm q-ml-sm">
|
||||
<q-item-label> <strong>Shipping Zone: </strong>
|
||||
<span v-text="order.shippingZone?.name || ''"></span>
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
<q-item-section class="q-mt-md q-ml-sm">
|
||||
<q-item-label> <strong>Invoice: </strong>
|
||||
<q-badge @click="showInvoice(order)" v-if="order.invoice?.human_readable_part?.amount"
|
||||
color="orange" class="cursor-pointer">
|
||||
<span
|
||||
v-text="formatCurrency(order.invoice?.human_readable_part?.amount / 1000, 'sat')"></span>
|
||||
</q-badge>
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
</q-card-section>
|
||||
</q-card-section>
|
||||
|
||||
|
||||
</q-expansion-item>
|
||||
<q-separator></q-separator>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -16,24 +16,26 @@ async function customerOrders(path) {
|
|||
},
|
||||
methods: {
|
||||
enrichOrder: function (order) {
|
||||
const stall = this.stallForOrder(order)
|
||||
return {
|
||||
...order,
|
||||
stallName: this.stallNameForOrder(order),
|
||||
invoice: this.invoiceForOrder(order)
|
||||
stallName: stall.name,
|
||||
shippingZone: stall.shipping.find(s => s.id === order.shipping_id),
|
||||
invoice: this.invoiceForOrder(order),
|
||||
products: this.getProductsForOrder(order)
|
||||
}
|
||||
},
|
||||
stallNameForOrder: function (order) {
|
||||
stallForOrder: function (order) {
|
||||
try {
|
||||
console.log('### stallNameForOrder', order)
|
||||
const productId = order.items[0]?.product_id
|
||||
if (!productId) return 'Stall Name'
|
||||
if (!productId) return
|
||||
const product = this.products.find(p => p.id === productId)
|
||||
if (!product) return 'Stall Name'
|
||||
if (!product) return
|
||||
const stall = this.stalls.find(s => s.id === product.stall_id)
|
||||
if (!stall) return 'Stall Name'
|
||||
return stall.name
|
||||
if (!stall) return
|
||||
return stall
|
||||
} catch (error) {
|
||||
return 'Stall Name'
|
||||
console.log(error)
|
||||
}
|
||||
|
||||
},
|
||||
|
|
@ -52,6 +54,14 @@ async function customerOrders(path) {
|
|||
return merchant?.profile
|
||||
},
|
||||
|
||||
getProductsForOrder: function (order) {
|
||||
if (!order?.items?.length) return []
|
||||
const productsIds = order.items.map(i => i.product_id)
|
||||
return this.products
|
||||
.filter(p => productsIds.indexOf(p.id) !== -1)
|
||||
.map(p => ({ ...p, orderedQuantity: order.items.find(i => i.product_id === p.id).quantity }))
|
||||
},
|
||||
|
||||
showInvoice: function (order) {
|
||||
if (order.paid) return
|
||||
const invoice = order?.payment_options?.find(p => p.type === 'ln').link
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue