fix: show empty cart if cart is empty

This commit is contained in:
kusowl 2026-03-25 15:48:14 +05:30
parent aa35fe44b3
commit 0c349d816c

View File

@ -1,31 +1,36 @@
<ul> <ul>
@if (authService.authState() === AuthState.Unauthenticated) { @if (authService.authState() === AuthState.Unauthenticated) {
<li><a class="block h-full w-full" routerLink="/login">Login to access cart</a></li> <li><a class="block h-full w-full" routerLink="/login">Login to access cart</a></li>
} @else if (authService.authState() === AuthState.Loading) { } @else if (authService.authState() === AuthState.Loading) {
<li><a class="block h-full w-full">Loading</a></li> <li><a class="block h-full w-full">Loading</a></li>
} @else { } @else {
<ol <ol
[class.pointer-events-none]="isLoading()" [class.cursor-block]="isLoading()"
[class.opacity-40]="isLoading()" [class.opacity-40]="isLoading()"
[class.cursor-block]="isLoading()" [class.pointer-events-none]="isLoading()"
class="rounded-none!" class="rounded-none!"
> >
@for (item of cart.items; track item.id) { @for (item of cart.items; track item.id) {
<app-cart-item <app-cart-item
(qtyChangeEvent)="updateProductQty($event)" (productDeleteEvent)="removeProduct($event)"
(productDeleteEvent)="removeProduct($event)" (qtyChangeEvent)="updateProductQty($event)"
[cartItem]="item" [cartItem]="item"
/> />
}
</ol>
@if (cart.itemsCount > 0) {
<div class="flex justify-between mt-4 px-2 font-bold text-lg">
<p>Total</p>
<p>Rs. {{ cart.totalPrice }}</p>
</div>
<li class="pt-4! mt-4 border-t border-gray-200 rounded-none!">
<a [routerLink]="`/checkout/address`" class="btn btn-primary px-4">Proceed to checkout</a>
</li>
} }
</ol> @else{
<li><a class="block h-full w-full">Cart is empty !</a></li>
<div class="flex justify-between mt-4 px-2 font-bold text-lg"> }
<p>Total</p>
<p>Rs. {{ cart.totalPrice }}</p>
</div>
<li class="pt-4! mt-4 border-t border-gray-200 rounded-none!">
<a [routerLink]="`/checkout/address`" class="btn btn-primary px-4">Proceed to checkout</a>
</li>
} }
</ul> </ul>