-
Notifications
You must be signed in to change notification settings - Fork 0
/
Item.vue
44 lines (42 loc) · 1016 Bytes
/
Item.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<template>
<div class="flex items-center">
<img class="w-12 h-12 rounded shadow overflow-hidden" :src="product.image" alt="">
<h3 class="flex-grow mx-2">
{{ product.display }}
<span v-if="product.quantity > 1" class="text-gray-500">
x{{ product.quantity }}
</span>
</h3>
<button
class="text-sm text-red-600 py-1 px-2 transition-colors hover:bg-black hover:bg-opacity-30 rounded"
@click="remove"
>
<span v-if="removingFromCart">Removing..</span>
<span v-else>Remove</span>
</button>
</div>
</template>
<script>
import { mapActions } from 'vuex'
export default {
props: {
product: {
type: Object,
required: true
}
},
data () {
return {
removingFromCart: false
}
},
methods: {
...mapActions('fastspring', ['removeFromCart']),
async remove () {
this.removingFromCart = true
await this.removeFromCart(this.product.pid)
this.removingFromCart = false
}
}
}
</script>