Skip to content

Commit 11050f4

Browse files
committed
Refactor CartContents to use store loading and error state
Replaces local isLoading and error refs with computed properties that reflect the cart store's loading and error state. Removes onMounted refetch logic in favor of relying on the store's state management.
1 parent 46dfc31 commit 11050f4

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

components/Cart/CartContents.vue

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* @module CartContents
3333
* @returns {Object} The Vue.js component object.
3434
*/
35-
import { computed, ref, onMounted } from "vue";
35+
import { computed } from "vue";
3636
import { useCart } from "@/store/useCart";
3737
3838
const props = defineProps({
@@ -43,9 +43,10 @@ const props = defineProps({
4343
});
4444
4545
const cart = useCart();
46-
const isLoading = ref(true);
47-
const error = ref(null);
4846
47+
// Use the store's reactive state directly
48+
const isLoading = computed(() => cart.loading);
49+
const error = computed(() => cart.error);
4950
const cartItems = computed(() => cart.cart);
5051
5152
/**
@@ -59,16 +60,6 @@ const handleRemoveProduct = async (key) => {
5960
} catch (error) {}
6061
};
6162
62-
onMounted(async () => {
63-
try {
64-
await cart.refetch();
65-
} catch (err) {
66-
error.value = err;
67-
} finally {
68-
isLoading.value = false;
69-
}
70-
});
71-
7263
/**
7364
* Handles updating the quantity of a cart item.
7465
*

0 commit comments

Comments
 (0)