Skip to content

Commit 46dfc31

Browse files
committed
Refactor cart loading and error state handling
Replaces local isLoading and error refs with computed properties that directly use the store's reactive state. Removes unnecessary onMounted logic for fetching cart data.
1 parent c42ac31 commit 46dfc31

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

components/Layout/LayoutCart.vue

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,15 @@
4848
</template>
4949

5050
<script setup>
51-
import { ref, computed, onMounted } from "vue";
51+
import { computed } from "vue";
5252
import { useCart } from "@/store/useCart";
5353
import { formatPrice } from "@/utils/functions";
5454
5555
const cart = useCart();
56-
const isLoading = ref(true);
57-
const error = ref(null);
5856
57+
// Use the store's reactive state directly
58+
const isLoading = computed(() => cart.loading);
59+
const error = computed(() => cart.error);
5960
const cartLength = computed(() => cart.cartQuantity);
6061
const cartSubtotal = computed(() => cart.cartSubtotal);
61-
62-
onMounted(async () => {
63-
try {
64-
await cart.refetch();
65-
} catch (err) {
66-
error.value = err;
67-
} finally {
68-
isLoading.value = false;
69-
}
70-
});
7162
</script>

0 commit comments

Comments
 (0)