feat(profile): enhance ChargeCreditWallet and Wallet components with club membership checks
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 4m42s
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 4m42s
- Added logic to display alerts and buttons based on club membership status in the ChargeCreditWallet and Wallet components. - Implemented user authentication checks to determine if the user is a club member and has purchased a package before allowing wallet charging. - Updated UI to guide users on purchasing packages or signing club contracts if they are not eligible to charge their wallet. These changes improve user experience by providing clear instructions and preventing unauthorized wallet charges.
This commit is contained in:
@@ -7,10 +7,15 @@ namespace FrontOffice.Main.Pages.Profile;
|
||||
|
||||
public partial class ChargeCreditWallet : ComponentBase
|
||||
{
|
||||
[Inject] private AuthService AuthService { get; set; } = default!;
|
||||
|
||||
private bool _isProcessing;
|
||||
private long _chargeAmount;
|
||||
private string? _paymentResult;
|
||||
private string? _pendingReturnUrl;
|
||||
private bool _isClubMemberActive;
|
||||
private bool _hasPurchasedPackage;
|
||||
private bool _authLoaded;
|
||||
|
||||
private readonly long[] _presetAmounts = { 500_000, 1_000_000, 5_000_000, 10_000_000, 20_000_000, 50_000_000 };
|
||||
|
||||
@@ -23,7 +28,7 @@ public partial class ChargeCreditWallet : ComponentBase
|
||||
[SupplyParameterFromQuery(Name = "returnUrl")]
|
||||
public string? ReturnUrlQueryParam { get; set; }
|
||||
|
||||
protected override void OnInitialized()
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_paymentResult = PaymentQueryParam;
|
||||
|
||||
@@ -32,11 +37,27 @@ public partial class ChargeCreditWallet : ComponentBase
|
||||
|
||||
if (CreditChargeNavigation.IsValidReturnUrl(ReturnUrlQueryParam))
|
||||
_pendingReturnUrl = ReturnUrlQueryParam;
|
||||
|
||||
try
|
||||
{
|
||||
var userInfo = await AuthService.GetUserAuthInfo();
|
||||
_isClubMemberActive = userInfo.IsClubMemberActive;
|
||||
_hasPurchasedPackage = userInfo.HasPurchasedPackage;
|
||||
}
|
||||
catch
|
||||
{
|
||||
_isClubMemberActive = false;
|
||||
_hasPurchasedPackage = false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_authLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender && !string.IsNullOrEmpty(_pendingReturnUrl))
|
||||
if (firstRender && !string.IsNullOrEmpty(_pendingReturnUrl) && _isClubMemberActive)
|
||||
{
|
||||
await CreditChargeNavigation.SaveReturnUrlAsync(JSRuntime, _pendingReturnUrl);
|
||||
}
|
||||
@@ -46,6 +67,14 @@ public partial class ChargeCreditWallet : ComponentBase
|
||||
|
||||
private async Task StartCreditCharge()
|
||||
{
|
||||
if (!_isClubMemberActive)
|
||||
{
|
||||
Snackbar.Add(
|
||||
"برای شارژ کیف پول اصلی ابتدا باید پکیج را خریداری کرده و قرارداد باشگاه مشتریان را امضا کنید.",
|
||||
Severity.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_chargeAmount <= 0 || _isProcessing) return;
|
||||
|
||||
_isProcessing = true;
|
||||
|
||||
Reference in New Issue
Block a user