Skip to content

Commit f37a2df

Browse files
committed
Improve cart loading and error UI handling
Loading and error messages are now only shown when the cart is empty. When cart items are present and loading, an 'updating...' indicator is displayed and the cart section is visually dimmed to indicate loading state.
1 parent 64078df commit f37a2df

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

components/Cart/CartContents.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
<template>
2-
<div v-if="isLoading">
2+
<div v-if="isLoading && cartItems.length === 0">
33
<h2 class="mt-64 text-3xl text-center">Loading cart...</h2>
44
</div>
5-
<div v-else-if="error">
5+
<div v-else-if="error && cartItems.length === 0">
66
<h2 class="mt-64 text-3xl text-center text-red-500">
77
Error loading cart. Please try again.
88
</h2>
99
</div>
1010
<div v-else-if="cartItems.length">
11-
<h1 class="h-10 p-6 text-3xl font-bold text-center">Cart</h1>
12-
<section class="mt-10">
11+
<h1 class="h-10 p-6 text-3xl font-bold text-center">
12+
Cart
13+
<span v-if="isLoading" class="text-sm text-gray-500 ml-2">(updating...)</span>
14+
</h1>
15+
<section class="mt-10" :class="{ 'opacity-70': isLoading }">
1316
<CartItem
1417
v-for="product in cartItems"
1518
:key="product.key"

0 commit comments

Comments
 (0)