changes
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
<script setup>
|
||||
const props = defineProps({
|
||||
cartItem: Object,
|
||||
deleteable: Boolean,
|
||||
});
|
||||
const { $deleteapi, $numtoString, $snackbar } = useNuxtApp();
|
||||
const { getCart } = inject("pos");
|
||||
const showConfirmModal = ref();
|
||||
const isDeleting = ref(false);
|
||||
|
||||
function openConfirmModal() {
|
||||
showConfirmModal.value = {
|
||||
@@ -17,9 +20,10 @@ function openConfirmModal() {
|
||||
};
|
||||
}
|
||||
|
||||
const getCart = inject("getCart");
|
||||
async function removeFromCart() {
|
||||
isDeleting.value = true;
|
||||
await $deleteapi("Cart_Item", props.cartItem.id);
|
||||
isDeleting.value = false;
|
||||
$snackbar("Đã xoá sản phẩm khỏi giỏ hàng", "Success");
|
||||
getCart();
|
||||
}
|
||||
@@ -51,8 +55,9 @@ async function removeFromCart() {
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
v-if="deleteable"
|
||||
@click="openConfirmModal"
|
||||
class="button is-danger is-light"
|
||||
:class="['button is-danger is-light', isDeleting && 'is-loading']"
|
||||
>
|
||||
<span class="icon">
|
||||
<Icon
|
||||
|
||||
Reference in New Issue
Block a user