8e98c50bdf
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 5m29s
- Added new logic to handle user consent for charging without a magic multiplier when the magic wallet ceiling is full. - Updated the ChargeCreditWallet component to display alerts and prompts based on the user's magic wallet status and consent. - Enhanced the Wallet component to conditionally render buttons and alerts related to the magic wallet ceiling status. - Improved user feedback in the InsufficientCreditDialog to guide users on charging options based on their wallet status. These changes enhance the user experience by providing clear instructions and options for charging wallets under specific conditions.
69 lines
2.1 KiB
C#
69 lines
2.1 KiB
C#
using FrontOffice.Main.Utilities;
|
|
using Microsoft.AspNetCore.Components;
|
|
using MudBlazor;
|
|
|
|
namespace FrontOffice.Main.Pages.Profile;
|
|
|
|
public partial class Wallet : ComponentBase
|
|
{
|
|
[Inject] private AuthService AuthService { get; set; } = default!;
|
|
|
|
private (string Credit, string Discount, string Network) _balances = ("-", "-", "-");
|
|
private List<WalletTransaction> _txs = new();
|
|
private string? _filterReferenceId;
|
|
private string _filterType = "all";
|
|
private bool _isClubMemberActive;
|
|
private bool _hasPurchasedPackage;
|
|
private bool _isMagicWallet;
|
|
private bool _magicCeilingFull;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
try
|
|
{
|
|
var userInfo = await AuthService.GetUserAuthInfo();
|
|
_isClubMemberActive = userInfo.IsClubMemberActive;
|
|
_hasPurchasedPackage = userInfo.HasPurchasedPackage;
|
|
}
|
|
catch
|
|
{
|
|
_isClubMemberActive = false;
|
|
_hasPurchasedPackage = false;
|
|
}
|
|
|
|
try
|
|
{
|
|
var magicStatus = await WalletService.GetMagicWalletStatusAsync();
|
|
_isMagicWallet = magicStatus.WalletMode == 1;
|
|
_magicCeilingFull = _isMagicWallet && magicStatus.MagicRemainingDeposit <= 0;
|
|
}
|
|
catch
|
|
{
|
|
_isMagicWallet = false;
|
|
_magicCeilingFull = false;
|
|
}
|
|
|
|
var b = await WalletService.GetBalancesAsync();
|
|
_balances = (FormatPrice(b.CreditBalance), FormatPrice(b.DiscountBalance), FormatPrice(b.NetworkBalance));
|
|
_txs = await WalletService.GetTransactionsAsync();
|
|
}
|
|
|
|
private static string FormatPrice(long price) => string.Format("{0:N0} تومان", price);
|
|
|
|
private async Task ApplyFilters()
|
|
{
|
|
long? refId = null;
|
|
if (long.TryParse(_filterReferenceId, out var parsed) && parsed > 0)
|
|
{
|
|
refId = parsed;
|
|
}
|
|
bool? isIncrease = _filterType switch
|
|
{
|
|
"in" => true,
|
|
"out" => false,
|
|
_ => null
|
|
};
|
|
_txs = await WalletService.GetTransactionsAsync(refId, isIncrease);
|
|
}
|
|
}
|