This commit is contained in:
@@ -34,7 +34,7 @@ public partial class BookCard
|
||||
|
||||
CartService.AddItem(productPriceFetch.Value, bookFetch.Value.Product!, authorFetch.Value);
|
||||
|
||||
ToastService.ShowSuccess($"Added '{Title}' to your order.", "Add To Cart");
|
||||
ToastService.ShowSuccess($"Added '{Title}' to your order.", "Cart Changed");
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@@ -5,13 +5,13 @@ namespace MidrandBookshop.Components.Layout;
|
||||
|
||||
public partial class MainLayout(CartService cartService) : IDisposable
|
||||
{
|
||||
[Inject]
|
||||
private AuthenticationStateProvider AuthStateProvider { get; set; } = default!;
|
||||
[Inject] private AuthenticationStateProvider AuthStateProvider { get; set; } = default!;
|
||||
[Inject] public IToastService ToastService { get; set; } = default!;
|
||||
|
||||
private Cart ShoppingCart => cartService.ShoppingCart;
|
||||
|
||||
private AuthenticationState? AuthState { get; set; }
|
||||
private System.Security.Claims.ClaimsPrincipal? User { get; set; }
|
||||
private ClaimsPrincipal? User { get; set; }
|
||||
private bool IsAuthenticated => User?.Identity?.IsAuthenticated ?? false;
|
||||
|
||||
private string SearchInputBuffer { get; set; } = string.Empty;
|
||||
@@ -116,6 +116,8 @@ public partial class MainLayout(CartService cartService) : IDisposable
|
||||
cartService.RemoveOneItem(item.Price!.Id);
|
||||
|
||||
await cartService.SaveCartToStorageAsync();
|
||||
|
||||
ToastService.ShowSuccess($"Removed {item.Product!.Name} from cart", "Cart Changed");
|
||||
}
|
||||
|
||||
private decimal GetCartTotal() => ShoppingCart?.TotalAmount ?? 0.00m;
|
||||
|
||||
@@ -5,6 +5,8 @@ namespace MidrandBookshop.Components.Pages;
|
||||
|
||||
public partial class CartReview(CartService cartService)
|
||||
{
|
||||
[Inject] public IToastService ToastService { get; set; } = default!;
|
||||
|
||||
protected Cart ShoppingCart => cartService?.ShoppingCart!;
|
||||
|
||||
protected async void IncreaseQty(CartItem item)
|
||||
@@ -32,5 +34,7 @@ public partial class CartReview(CartService cartService)
|
||||
cartService.RemoveOneItem(item.Price!.Id);
|
||||
|
||||
await cartService.SaveCartToStorageAsync();
|
||||
|
||||
ToastService.ShowSuccess($"Removed {item.Product!.Name} from cart", "Cart Changed");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ public partial class Checkout()
|
||||
[Inject] private AuthenticationStateProvider AuthStateProvider { get; set; } = default!;
|
||||
[Inject] public IJSRuntime JSRuntime { get; set; } = default!;
|
||||
[Inject] private CancellationToken CancellationToken { get; set; } = default!;
|
||||
[Inject] public IToastService ToastService { get; set; } = default!;
|
||||
|
||||
private Cart ShoppingCart => CartService.ShoppingCart;
|
||||
private ClaimsPrincipal? User { get; set; }
|
||||
@@ -63,7 +64,12 @@ public partial class Checkout()
|
||||
|
||||
private async Task PayNow(MouseEventArgs args)
|
||||
{
|
||||
if (IsProcessing) return;
|
||||
if (IsProcessing)
|
||||
{
|
||||
ToastService.ShowWarning("Please wait, completing your payment", "Busy...");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
@@ -111,7 +117,12 @@ public partial class Checkout()
|
||||
{
|
||||
var paymentFetch = await PaymentService.GetOrderPaymentAsync(orderId, CancellationToken);
|
||||
|
||||
if (paymentFetch.IsFailed) return;
|
||||
if (paymentFetch.IsFailed)
|
||||
{
|
||||
ToastService.ShowError("Failed to get fetch your previously made payment", "Payment Check");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
paymentId = paymentFetch.Value.Id;
|
||||
}
|
||||
@@ -150,8 +161,10 @@ public partial class Checkout()
|
||||
|
||||
await JSRuntime.InvokeVoidAsync("eval", "document.getElementById('payfastForm').submit();");
|
||||
}
|
||||
catch
|
||||
catch(Exception ex)
|
||||
{
|
||||
ToastService.ShowError($"Failed to perform checkout: {ex.Message}", "Checkout");
|
||||
|
||||
IsProcessing = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ public partial class PaymentSuccess
|
||||
[Inject] private HashService HashService { get; set; } = default!;
|
||||
[Inject] private AuthenticationStateProvider AuthStateProvider { get; set; } = default!;
|
||||
[Inject] private CancellationToken CancellationToken { get; set; } = default!;
|
||||
[Inject] public IToastService ToastService { get; set; } = default!;
|
||||
|
||||
[Parameter]
|
||||
[SupplyParameterFromQuery(Name = "reference")]
|
||||
|
||||
Reference in New Issue
Block a user