Skip to content

Commit ba3cdaa

Browse files
committed
Refactor cart removal and loading state formatting
Simplified the isLastItem assignment in removeProductFromCart and improved formatting for the loading computed property for better readability.
1 parent 0d49212 commit ba3cdaa

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

store/useCart.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ export const useCart = defineStore(
9696

9797
const removeProductFromCart = async (key) => {
9898
try {
99-
const isLastItem =
100-
cart.value.length === 1 && cart.value[0].key === key;
99+
const isLastItem = cart.value.length === 1 && cart.value[0].key === key;
101100
await updateCartItemQuantity(key, 0);
102101
if (isLastItem) {
103102
updateCartState(null); // Clear cart locally to update UI instantly
@@ -133,7 +132,8 @@ export const useCart = defineStore(
133132
return {
134133
cart,
135134
loading: computed(
136-
() => loading.value || addToCartLoading.value || updateCartLoading.value,
135+
() =>
136+
loading.value || addToCartLoading.value || updateCartLoading.value,
137137
),
138138
error,
139139
cartTotals,

0 commit comments

Comments
 (0)