This commit is contained in:
@@ -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