This commit is contained in:
Viet An
2026-06-10 15:39:58 +07:00
parent 22c284f1ef
commit d0b12dc647
11 changed files with 305 additions and 283 deletions

View File

@@ -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