feat: UI stuff
This commit is contained in:
parent
8e2bc8bb92
commit
761cf02a34
3 changed files with 34 additions and 76 deletions
|
|
@ -69,6 +69,14 @@
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
</template>
|
</template>
|
||||||
<q-separator></q-separator>
|
<q-separator></q-separator>
|
||||||
|
<q-card-section class="col-12">
|
||||||
|
<q-item-section>
|
||||||
|
<q-item-label> <strong>Order ID: </strong> <span v-text="order.id"></span>
|
||||||
|
</q-item-label>
|
||||||
|
</q-item-section>
|
||||||
|
|
||||||
|
</q-card-section>
|
||||||
|
<q-separator></q-separator>
|
||||||
<q-card-section horizontal>
|
<q-card-section horizontal>
|
||||||
|
|
||||||
<q-card-section class="col-7">
|
<q-card-section class="col-7">
|
||||||
|
|
@ -120,35 +128,8 @@
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
<q-separator></q-separator>
|
|
||||||
<q-card-section class="col-12">
|
<q-separator class="q-mb-xl"></q-separator>
|
||||||
<q-item-section class="q-mt-sm q-ml-sm">
|
|
||||||
<q-item-label> <strong>Order ID: </strong>
|
|
||||||
</q-item-label>
|
|
||||||
</q-item-section>
|
|
||||||
<q-item-section class="q-mt-sm">
|
|
||||||
<q-item-label>
|
|
||||||
<span v-text="order.id"></span>
|
|
||||||
</q-item-label>
|
|
||||||
</q-item-section>
|
|
||||||
</q-card-section>
|
|
||||||
<q-card-section v-if="order.messages" class="col-12">
|
|
||||||
<q-item-section class="q-mt-sm q-ml-sm">
|
|
||||||
<q-item-label> <strong>Messages: </strong>
|
|
||||||
</q-item-label>
|
|
||||||
</q-item-section>
|
|
||||||
<q-item-section class="q-mt-sm">
|
|
||||||
<q-item-label>
|
|
||||||
<ul>
|
|
||||||
<li v-for="(message, i) in order.messages" :key="i">
|
|
||||||
<span v-text="message"></span>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
</q-item-label>
|
|
||||||
</q-item-section>
|
|
||||||
</q-card-section>
|
|
||||||
|
|
||||||
</q-expansion-item>
|
</q-expansion-item>
|
||||||
<q-separator></q-separator>
|
<q-separator></q-separator>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ async function shoppingCartCheckout(path) {
|
||||||
pubkey: this.customerPubkey
|
pubkey: this.customerPubkey
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$emit('place-order', { event, order })
|
this.$emit('place-order', { event, order, cartId: this.cart.id })
|
||||||
|
|
||||||
},
|
},
|
||||||
goToShoppingCart: function () {
|
goToShoppingCart: function () {
|
||||||
|
|
|
||||||
|
|
@ -105,39 +105,6 @@ const market = async () => {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
// allOrders() {
|
|
||||||
// console.log('### allOrders compute')
|
|
||||||
// const prefix = 'nostrmarket.orders.'
|
|
||||||
|
|
||||||
// return Object.keys(this.orders).map((key) => ({
|
|
||||||
// pubkey: key.substring(prefix.length),
|
|
||||||
// orders: this.orders[key]
|
|
||||||
// }), {})
|
|
||||||
// },
|
|
||||||
orderedProducts: function () {
|
|
||||||
const allItems = Object.keys(this.orders)
|
|
||||||
.map(pubkey => this.orders[pubkey]
|
|
||||||
.map(o => o.items)
|
|
||||||
.flat()
|
|
||||||
.map(i => i.product_id)
|
|
||||||
.flat())
|
|
||||||
.flat()
|
|
||||||
const uniqueProductIds = [...new Set(allItems)];
|
|
||||||
return this.products.filter(p => uniqueProductIds.indexOf(p.id) !== -1)
|
|
||||||
},
|
|
||||||
orderedStalls: function () {
|
|
||||||
const allItems = Object.keys(this.orders)
|
|
||||||
.map(pubkey => this.orders[pubkey]
|
|
||||||
.map(o => o.items)
|
|
||||||
.flat()
|
|
||||||
.map(i => i.product_id)
|
|
||||||
.flat())
|
|
||||||
.flat()
|
|
||||||
const uniqueProductIds = [...new Set(allItems)];
|
|
||||||
const uniqueStallIds = this.products.filter(p => uniqueProductIds.indexOf(p.id) !== -1).map(p => p.stall_id)
|
|
||||||
|
|
||||||
return this.stalls.filter(s => uniqueStallIds.indexOf(s.id) !== -1)
|
|
||||||
},
|
|
||||||
filterProducts() {
|
filterProducts() {
|
||||||
let products = this.products
|
let products = this.products
|
||||||
console.log('### this.products', this.products)
|
console.log('### this.products', this.products)
|
||||||
|
|
@ -669,8 +636,8 @@ const market = async () => {
|
||||||
this.$q.localStorage.set('nostrmarket.shoppingCarts', this.shoppingCarts)
|
this.$q.localStorage.set('nostrmarket.shoppingCarts', this.shoppingCarts)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
removeCart(stallId) {
|
removeCart(cartId) {
|
||||||
this.shoppingCarts = this.shoppingCarts.filter(s => s.id !== stallId)
|
this.shoppingCarts = this.shoppingCarts.filter(s => s.id !== cartId)
|
||||||
this.$q.localStorage.set('nostrmarket.shoppingCarts', this.shoppingCarts)
|
this.$q.localStorage.set('nostrmarket.shoppingCarts', this.shoppingCarts)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -680,23 +647,33 @@ const market = async () => {
|
||||||
this.setActivePage('shopping-cart-checkout')
|
this.setActivePage('shopping-cart-checkout')
|
||||||
},
|
},
|
||||||
|
|
||||||
async placeOrder({ event, order }) {
|
async placeOrder({ event, order, cartId }) {
|
||||||
if (!this.account.privkey) {
|
if (!this.account.privkey) {
|
||||||
this.openAccountDialog()
|
this.openAccountDialog()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.activeOrderId = order.id
|
try {
|
||||||
event.content = await NostrTools.nip04.encrypt(
|
this.activeOrderId = order.id
|
||||||
this.account.privkey,
|
event.content = await NostrTools.nip04.encrypt(
|
||||||
this.checkoutStall.pubkey,
|
this.account.privkey,
|
||||||
JSON.stringify(order)
|
this.checkoutStall.pubkey,
|
||||||
)
|
JSON.stringify(order)
|
||||||
|
)
|
||||||
|
|
||||||
event.id = NostrTools.getEventHash(event)
|
event.id = NostrTools.getEventHash(event)
|
||||||
event.sig = await NostrTools.signEvent(event, this.account.privkey)
|
event.sig = await NostrTools.signEvent(event, this.account.privkey)
|
||||||
|
|
||||||
this.sendOrderEvent(event)
|
this.sendOrderEvent(event)
|
||||||
this.persistOrderUpdate(this.checkoutStall.pubkey, event.created_at, order)
|
this.persistOrderUpdate(this.checkoutStall.pubkey, event.created_at, order)
|
||||||
|
this.removeCart(cartId)
|
||||||
|
this.setActivePage('shopping-cart-list')
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(error)
|
||||||
|
this.$q.notify({
|
||||||
|
type: 'warning',
|
||||||
|
message: 'Failed to place order!'
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
sendOrderEvent(event) {
|
sendOrderEvent(event) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue