Completed Cart page design
continuous-integration/drone/pr Build is passing

This commit is contained in:
Khwezi Mngoma
2026-06-11 00:23:57 +02:00
parent 64e0fcba27
commit e7acb05027
7 changed files with 125 additions and 95 deletions
@@ -0,0 +1,36 @@
using MidrandBookshop.Services.ShoppingCart;
using MidrandBookshop.Services.ShoppingCart.Models;
namespace MidrandBookshop.Components.Pages;
public partial class Cart(CartService cartService)
{
protected Services.ShoppingCart.Models.Cart ShoppingCart => cartService?.ShoppingCart!;
protected async void IncreaseQty(CartItem item)
{
if (item is not null)
{
cartService.UpdateQuantity(item!.Price!.Id, 1);
await cartService.SaveCartToStorageAsync();
}
}
protected async void DecreaseQty(CartItem item, int delta)
{
var peekQuantity = item.Quantity + delta;
if (peekQuantity < 1) return;
cartService.UpdateQuantity(item!.Price!.Id, delta);
await cartService.SaveCartToStorageAsync();
}
private async void RemoveFromCart(CartItem item)
{
cartService.RemoveOneItem(item.Price!.Id);
await cartService.SaveCartToStorageAsync();
}
}