feat(wallet): enhance ChargeCreditWallet and Wallet components with magic wallet functionality
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 5m28s

- Added logic to handle redirection and alerts for users with a magic wallet status in the ChargeCreditWallet component.
- Updated the Wallet component to conditionally render buttons and alerts based on the user's magic wallet status.
- Implemented a method to check the magic wallet status and provide user feedback regarding wallet charging options.

These changes improve user experience by clearly guiding users on the appropriate wallet charging methods based on their current wallet status.
This commit is contained in:
masoodafar-web
2026-08-08 22:22:03 +03:30
parent acad1a719f
commit 6123e47968
5 changed files with 95 additions and 12 deletions
@@ -16,6 +16,7 @@ public partial class ChargeCreditWallet : ComponentBase
private bool _isClubMemberActive;
private bool _hasPurchasedPackage;
private bool _authLoaded;
private bool _redirectingToMagic;
private readonly long[] _presetAmounts = { 500_000, 1_000_000, 5_000_000, 10_000_000, 20_000_000, 50_000_000 };
@@ -53,11 +54,15 @@ public partial class ChargeCreditWallet : ComponentBase
{
_authLoaded = true;
}
// اگر کیف پول جادویی فعال است، فرم شارژ ۱:۱ نشان داده نشود
if (_isClubMemberActive && await TryRedirectIfMagicWalletAsync())
return;
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender && !string.IsNullOrEmpty(_pendingReturnUrl) && _isClubMemberActive)
if (firstRender && !string.IsNullOrEmpty(_pendingReturnUrl) && _isClubMemberActive && !_redirectingToMagic)
{
await CreditChargeNavigation.SaveReturnUrlAsync(JSRuntime, _pendingReturnUrl);
}
@@ -75,6 +80,9 @@ public partial class ChargeCreditWallet : ComponentBase
return;
}
if (await TryRedirectIfMagicWalletAsync())
return;
if (_chargeAmount <= 0 || _isProcessing) return;
_isProcessing = true;
@@ -113,6 +121,35 @@ public partial class ChargeCreditWallet : ComponentBase
}
}
/// <summary>
/// اگر WalletMode جادویی باشد، پیام می‌دهد و به صفحه شارژ کیف جادویی هدایت می‌کند.
/// </summary>
private async Task<bool> TryRedirectIfMagicWalletAsync()
{
try
{
var status = await WalletService.GetMagicWalletStatusAsync();
if (status.WalletMode != 1)
return false;
var multiplier = status.MagicMultiplier > 0 ? status.MagicMultiplier : 2.5;
var multiplierText = multiplier.ToString("0.#");
_redirectingToMagic = true;
Snackbar.Add(
$"کیف پول شما در حالت جادویی است. شارژ از این صفحه موجودی را چندبرابر نمی‌کند. برای دریافت ضریب جادویی (×{multiplierText}) به صفحه شارژ کیف پول جادویی هدایت می‌شوید.",
Severity.Info);
Navigation.NavigateTo(RouteConstants.Profile.MagicWallet);
return true;
}
catch
{
// در صورت خطا در خواندن وضعیت، مانع شارژ عادی نشو
return false;
}
}
private async Task ContinueShoppingAsync()
{
var returnUrl = await CreditChargeNavigation.GetReturnUrlAsync(JSRuntime);