changes
This commit is contained in:
@@ -26,13 +26,14 @@ async function removeCart(cartId) {
|
||||
if (cartId === activeCartId.value) {
|
||||
if (carts.value.length === 1) {
|
||||
activeCartId.value = undefined;
|
||||
}
|
||||
const deletedCartIndex = carts.value.findIndex((c) => c.id === cartId);
|
||||
|
||||
if (deletedCartIndex === 0) {
|
||||
activeCartId.value = carts.value[deletedCartIndex + 1].id;
|
||||
} else {
|
||||
activeCartId.value = carts.value[deletedCartIndex - 1].id;
|
||||
const deletedCartIndex = carts.value.findIndex((c) => c.id === cartId);
|
||||
|
||||
if (deletedCartIndex === 0) {
|
||||
activeCartId.value = carts.value[deletedCartIndex + 1].id;
|
||||
} else {
|
||||
activeCartId.value = carts.value[deletedCartIndex - 1].id;
|
||||
}
|
||||
}
|
||||
}
|
||||
getCarts();
|
||||
@@ -74,6 +75,7 @@ async function removeCart(cartId) {
|
||||
<span
|
||||
@click.stop="removeCart(cart.id)"
|
||||
class="close ml-auto icon rounded-full"
|
||||
title="Xoá giỏ hàng"
|
||||
>
|
||||
<Icon name="material-symbols:close-rounded" />
|
||||
</span>
|
||||
|
||||
Reference in New Issue
Block a user