feat: show total cart item count

This commit is contained in:
Vlad Stan 2023-07-07 10:13:46 +03:00
parent 2b0664b613
commit e1b2a4a479
2 changed files with 13 additions and 5 deletions

View file

@ -124,6 +124,10 @@ const market = async () => {
},
canEditConfig() {
return this.account && this.account.pubkey == this.config?.pubkey
},
allCartsItemCount() {
return this.shoppingCarts.map(s => s.products).flat().reduce((t, p) => t + p.orderedQuantity, 0)
}
},
async created() {
@ -567,8 +571,6 @@ const market = async () => {
},
addProductToCart(item) {
console.log('### addProductToCart:', item)
let stallCart = this.shoppingCarts.find(s => s.id === item.stall_id)
if (!stallCart) {
stallCart = {

View file

@ -181,10 +181,16 @@
<q-btn v-else @click="accountDialog.show = true" color="gray" icon="person_add" flat
size="lg"><q-tooltip>User
Config</q-tooltip></q-btn>
<q-btn color="gray" icon="shopping_cart" flat size="lg"
@click="setActivePage('shopping-cart-list')"><q-tooltip>Shopping
Cart</q-tooltip></q-btn>
<q-btn color="gray" icon="shopping_cart" dense round flat size="lg"
@click="setActivePage('shopping-cart-list')">
<q-tooltip>Shopping Cart</q-tooltip>
<q-badge v-if="allCartsItemCount" color="secondary" floating>
<span v-text="allCartsItemCount"></span>
</q-badge>
</q-btn>
</div>
</q-toolbar>
</div>