feat(wallet): enhance ChargeCreditWallet and Wallet components with magic wallet functionality
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 5m28s
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:
@@ -1,3 +1,4 @@
|
||||
# Docs moved to totalDoc
|
||||
|
||||
See [totalDoc/INDEX.md](../../totalDoc/INDEX.md) for all documentation.
|
||||
|
||||
@@ -35,7 +35,23 @@
|
||||
</MudAlert>
|
||||
}
|
||||
|
||||
@if (_authLoaded && !_isClubMemberActive)
|
||||
@if (_authLoaded && _redirectingToMagic)
|
||||
{
|
||||
<MudAlert Severity="MudBlazor.Severity.Info" Class="rounded-lg" Variant="Variant.Outlined">
|
||||
<MudStack Spacing="2" AlignItems="AlignItems.Center">
|
||||
<MudProgressCircular Size="Size.Small" Indeterminate="true" Color="Color.Primary" />
|
||||
<MudText>
|
||||
کیف پول شما در حالت جادویی است. در حال انتقال به صفحه شارژ کیف پول جادویی...
|
||||
</MudText>
|
||||
<MudButton Size="Size.Small" Variant="Variant.Filled" Color="Color.Primary"
|
||||
Href="@RouteConstants.Profile.MagicWallet"
|
||||
StartIcon="@Icons.Material.Filled.AutoAwesome">
|
||||
رفتن به شارژ کیف جادویی
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
</MudAlert>
|
||||
}
|
||||
else if (_authLoaded && !_isClubMemberActive)
|
||||
{
|
||||
<MudAlert Severity="MudBlazor.Severity.Warning" Class="rounded-lg" Variant="Variant.Outlined">
|
||||
<MudStack Spacing="2">
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -38,18 +38,36 @@
|
||||
درخواستهای برداشت
|
||||
</MudButton>
|
||||
|
||||
<!-- دکمه شارژ کیفپول اصلی -->
|
||||
<!-- دکمه شارژ کیفپول اصلی / جادویی -->
|
||||
@if (_isClubMemberActive)
|
||||
{
|
||||
<MudButton Variant="Variant.Filled"
|
||||
Color="Color.Primary"
|
||||
Size="Size.Large"
|
||||
FullWidth="true"
|
||||
StartIcon="@Icons.Material.Filled.AccountBalanceWallet"
|
||||
Href="@RouteConstants.Profile.ChargeCreditWallet"
|
||||
Class="rounded-lg">
|
||||
شارژ کیفپول اصلی
|
||||
</MudButton>
|
||||
@if (_isMagicWallet)
|
||||
{
|
||||
<MudButton Variant="Variant.Filled"
|
||||
Color="Color.Secondary"
|
||||
Size="Size.Large"
|
||||
FullWidth="true"
|
||||
StartIcon="@Icons.Material.Filled.AutoAwesome"
|
||||
Href="@RouteConstants.Profile.MagicWallet"
|
||||
Class="rounded-lg">
|
||||
شارژ کیفپول جادویی
|
||||
</MudButton>
|
||||
<MudAlert Severity="Severity.Info" Dense="true" Variant="Variant.Outlined">
|
||||
کیف پول شما در حالت جادویی است؛ شارژ از مسیر جادویی با ضریب چندبرابر اعمال میشود.
|
||||
</MudAlert>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudButton Variant="Variant.Filled"
|
||||
Color="Color.Primary"
|
||||
Size="Size.Large"
|
||||
FullWidth="true"
|
||||
StartIcon="@Icons.Material.Filled.AccountBalanceWallet"
|
||||
Href="@RouteConstants.Profile.ChargeCreditWallet"
|
||||
Class="rounded-lg">
|
||||
شارژ کیفپول اصلی
|
||||
</MudButton>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -14,6 +14,7 @@ public partial class Wallet : ComponentBase
|
||||
private string _filterType = "all";
|
||||
private bool _isClubMemberActive;
|
||||
private bool _hasPurchasedPackage;
|
||||
private bool _isMagicWallet;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
@@ -29,6 +30,16 @@ public partial class Wallet : ComponentBase
|
||||
_hasPurchasedPackage = false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var magicStatus = await WalletService.GetMagicWalletStatusAsync();
|
||||
_isMagicWallet = magicStatus.WalletMode == 1;
|
||||
}
|
||||
catch
|
||||
{
|
||||
_isMagicWallet = false;
|
||||
}
|
||||
|
||||
var b = await WalletService.GetBalancesAsync();
|
||||
_balances = (FormatPrice(b.CreditBalance), FormatPrice(b.DiscountBalance), FormatPrice(b.NetworkBalance));
|
||||
_txs = await WalletService.GetTransactionsAsync();
|
||||
|
||||
Reference in New Issue
Block a user