Added legal pages, contact and abut us
continuous-integration/drone/pr Build is passing

Redesigned account, checkout
Added stock management design elements
This commit is contained in:
Khwezi Mngoma
2026-06-16 23:32:44 +02:00
parent 5d614d2a94
commit 8d2efbeb4a
18 changed files with 1642 additions and 555 deletions
@@ -5,6 +5,7 @@ using LiteCharms.Features.MidrandBooks.Payments;
using LiteCharms.Features.MidrandBooks.Payments.Models;
using LiteCharms.Features.MidrandBooks.Products;
using LiteCharms.Features.MidrandBooks.Products.Models;
using Microsoft.AspNetCore.Components;
namespace MidrandBookshop.Components.Pages;
@@ -30,6 +31,9 @@ public partial class ProductView : ComponentBase
protected List<string> Thumbnails { get; private set; } = [];
protected int Quantity { get; private set; } = 1;
// Track real-time stock limits
protected int StockCount { get; private set; } = 5;
protected Author? CurrentAuthor { get; private set; }
protected override async Task OnParametersSetAsync()
@@ -48,6 +52,9 @@ public partial class ProductView : ComponentBase
CurrentProduct = productResult.Value;
AuthorName = CurrentProduct.Metadata?.Manufacturer ?? "Unknown Author";
// Mapping real stock integers if available on your Product metadata entity model
// StockCount = CurrentProduct.InventoryCount;
var priceResult = await ProductService.GetProductPriceAsync(BookId);
LivePrice = priceResult.IsSuccess ? priceResult.Value.Amount : 0m;
CurrentPrice = priceResult.IsSuccess ? priceResult.Value : null;
@@ -90,47 +97,52 @@ public partial class ProductView : ComponentBase
protected async void IncreaseQty()
{
if (CurrentPrice is not null)
// Enforce maximum stock bounds limits natively during counter picking
if (CurrentPrice is not null && Quantity < StockCount)
{
CartService.UpdateQuantity(CurrentPrice!.Id, 1);
Quantity = CartService.GetCartItemQuantity(ShoppingCart, CurrentPrice.Id);
await CartService.SaveCartToStorageAsync();
StateHasChanged();
}
}
protected async void DecreaseQty()
protected async void DecreaseQty()
{
if (Quantity >= 1)
if (Quantity > 1)
{
CartService.UpdateQuantity(CurrentPrice!.Id, -1);
Quantity = CartService.GetCartItemQuantity(ShoppingCart, CurrentPrice.Id);
await CartService.SaveCartToStorageAsync();
StateHasChanged();
}
}
protected async void HandleAddToCart()
{
if (CurrentProduct == null) return;
if (CurrentProduct == null || StockCount <= 0) return;
if (CurrentPrice is not null)
{
if(ShoppingCart.Items.Any(p => p.Price!.Id == CurrentPrice.Id))
if (ShoppingCart.Items.Any(p => p.Price!.Id == CurrentPrice.Id))
{
var currentInCart = CartService.GetCartItemQuantity(ShoppingCart, CurrentPrice.Id);
if (currentInCart >= StockCount) return;
CartService.UpdateQuantity(CurrentPrice.Id, 1);
await CartService.SaveCartToStorageAsync();
return;
}
CartService.AddItem(CurrentPrice, CurrentProduct, CurrentAuthor!);
Quantity = CartService.GetCartItemQuantity(ShoppingCart, CurrentPrice.Id);
await CartService.SaveCartToStorageAsync();
StateHasChanged();
}
}