fix: remove discount balance UI entirely — 100% discount auto-applied by server
Build and Deploy to Kubernetes / build-and-deploy (push) Has been cancelled

This commit is contained in:
masoodafar-web
2026-02-16 21:57:18 +03:30
parent 1dc60faf4a
commit 01b9f1eb98
2 changed files with 8 additions and 105 deletions
@@ -15,48 +15,15 @@ public partial class Checkout
private CustomerAddressModel? _selectedAddress;
private bool _loadingAddresses;
private long _discountBalance;
private string? _notes;
private bool _placing;
/// <summary>
/// Maximum discount allowed based on cart items' MaxDiscountPercent
/// </summary>
private long MaxAllowedDiscount => DiscountCart.TotalDiscount;
/// <summary>
/// Maximum the user can actually use = min(balance, allowed discount)
/// Always applied at 100% — no user selection
/// </summary>
private long MaxUsable => Math.Min(_discountBalance, MaxAllowedDiscount);
/// <summary>
/// Amount to be charged via payment gateway (total minus auto-applied discount)
/// </summary>
private long GatewayAmount => DiscountCart.TotalPrice - MaxUsable;
private bool CanPlaceOrder => DiscountCart.Items.Count > 0 && _selectedAddress is not null;
protected override async Task OnInitializedAsync()
{
await DiscountCart.EnsureInitializedAsync();
var addressTask = LoadAddresses();
var balanceTask = LoadDiscountBalance();
await Task.WhenAll(addressTask, balanceTask);
}
private async Task LoadDiscountBalance()
{
try
{
var balances = await WalletService.GetBalancesAsync();
_discountBalance = balances.DiscountBalance;
}
catch
{
_discountBalance = 0;
}
await LoadAddresses();
}
private async Task LoadAddresses()
@@ -98,10 +65,10 @@ public partial class Checkout
_placing = true;
try
{
// Always use maximum possible discount (100%)
// Always use 100% discount — send full price, server will apply max from wallet
var result = await DiscountOrderService.PlaceOrderAsync(
_selectedAddress.Id,
MaxUsable,
DiscountCart.TotalPrice,
_notes);
if (!result.Success)