nostrmarket/static/components/shopping-cart/shopping-cart.js
2023-03-23 16:34:26 +00:00

36 lines
670 B
JavaScript

async function shoppingCart(path) {
const template = await loadTemplateAsync(path)
Vue.component('shopping-cart', {
name: 'shopping-cart',
template,
props: [
'cart',
'cart-menu',
'add-to-cart',
'remove-from-cart',
'reset-cart',
'products'
],
data: function () {
return {}
},
computed: {},
methods: {
add(id) {
this.$emit(
'add-to-cart',
this.products.find(p => p.id == id)
)
},
remove(id) {
this.$emit(
'remove-from-cart',
this.products.find(p => p.id == id)
)
}
},
created() {}
})
}