feat: enhance WithdrawalRequests page with payout selection and improved submission logic; add sorting options for products
Build and Deploy / build (push) Successful in 1m18s
Build and Deploy / build (push) Successful in 1m18s
This commit is contained in:
@@ -11,35 +11,73 @@
|
||||
|
||||
<!-- فرم درخواست برداشت جدید -->
|
||||
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||
<MudText Typo="Typo.h6" Class="mb-2">ثبت درخواست برداشت جدید</MudText>
|
||||
<MudStack Spacing="2">
|
||||
<MudTextField @bind-Value="_withdrawPayoutId"
|
||||
Label="شناسه واریز (PayoutId)"
|
||||
Variant="Variant.Outlined"
|
||||
Type="MudBlazor.InputType.Number"
|
||||
Required="true" />
|
||||
<MudRadioGroup T="WithdrawalMethodClient" @bind-Value="_withdrawMethod" Row="true">
|
||||
<MudRadio T="WithdrawalMethodClient" Option="@WithdrawalMethodClient.Cash" Color="Color.Primary">برداشت نقدی (نیاز به شبا)</MudRadio>
|
||||
<MudRadio T="WithdrawalMethodClient" Option="@WithdrawalMethodClient.Diamond" Color="Color.Secondary">الماس/غیرنقدی</MudRadio>
|
||||
</MudRadioGroup>
|
||||
<MudTextField @bind-Value="_withdrawIban"
|
||||
Label="شماره شبا"
|
||||
Variant="Variant.Outlined"
|
||||
Disabled="_withdrawMethod == WithdrawalMethodClient.Diamond"
|
||||
Placeholder="IRxxxxxxxxxxxx"
|
||||
Adornment="Adornment.Start"
|
||||
AdornmentText="IR" />
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">
|
||||
حداقل مبلغ برداشت: @FormatPrice(_minWithdrawalAmount)
|
||||
</MudText>
|
||||
<MudButton Disabled="_isSubmittingWithdrawal"
|
||||
Variant="Variant.Filled"
|
||||
Color="Color.Primary"
|
||||
StartIcon="@Icons.Material.Filled.Outbound"
|
||||
OnClick="SubmitWithdrawal">
|
||||
@(_isSubmittingWithdrawal ? "در حال ثبت..." : "ثبت درخواست برداشت")
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
<MudText Typo="Typo.h6" Class="mb-3">ثبت درخواست برداشت جدید</MudText>
|
||||
|
||||
@if (!_availablePayouts.Any())
|
||||
{
|
||||
<MudAlert Severity="Severity.Info" Variant="Variant.Outlined" Class="mb-3">
|
||||
<MudText>در حال حاضر واریزی برای برداشت وجود ندارد.</MudText>
|
||||
</MudAlert>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudStack Spacing="2">
|
||||
<MudSelect T="CommissionPayoutDto" @bind-Value="_selectedPayout"
|
||||
Label="انتخاب واریز"
|
||||
Variant="Variant.Outlined"
|
||||
AnchorOrigin="Origin.BottomLeft"
|
||||
Required="true"
|
||||
ToStringFunc="@(p => p != null ? $"{p.WeekDisplayName} - {p.AmountFormatted}" : "")">
|
||||
@foreach (var payout in _availablePayouts)
|
||||
{
|
||||
<MudSelectItem T="CommissionPayoutDto" Value="@payout">
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center" Class="w-100">
|
||||
<MudText>@payout.WeekDisplayName</MudText>
|
||||
<MudChip T="string" Color="Color.Success" Size="Size.Small" Variant="Variant.Filled">
|
||||
@payout.AmountFormatted
|
||||
</MudChip>
|
||||
</MudStack>
|
||||
</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
|
||||
@if (_selectedPayout != null)
|
||||
{
|
||||
<MudAlert Severity="Severity.Success" Variant="Variant.Text" Dense="true">
|
||||
مبلغ قابل برداشت: <strong>@_selectedPayout.AmountFormatted</strong>
|
||||
</MudAlert>
|
||||
}
|
||||
|
||||
<MudRadioGroup T="WithdrawalMethodClient" @bind-Value="_withdrawMethod" Row="true">
|
||||
<MudRadio T="WithdrawalMethodClient" Value="@WithdrawalMethodClient.Cash" Color="Color.Primary">
|
||||
برداشت نقدی (نیاز به شبا)
|
||||
</MudRadio>
|
||||
<MudRadio T="WithdrawalMethodClient" Disabled="true" Value="@WithdrawalMethodClient.Diamond" Color="Color.Secondary">
|
||||
الماس/غیرنقدی
|
||||
</MudRadio>
|
||||
</MudRadioGroup>
|
||||
|
||||
<MudTextField @bind-Value="_withdrawIban"
|
||||
Label="شماره شبا"
|
||||
Variant="Variant.Outlined"
|
||||
Disabled="_withdrawMethod == WithdrawalMethodClient.Diamond"
|
||||
Placeholder="IRxxxxxxxxxxxx"
|
||||
Adornment="Adornment.Start"
|
||||
AdornmentText="IR" />
|
||||
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">
|
||||
حداقل مبلغ برداشت: @FormatPrice(_minWithdrawalAmount)
|
||||
</MudText>
|
||||
|
||||
<MudButton Disabled="@(_isSubmittingWithdrawal || _selectedPayout == null)"
|
||||
Variant="Variant.Filled"
|
||||
Color="Color.Primary"
|
||||
StartIcon="@Icons.Material.Filled.Outbound"
|
||||
OnClick="SubmitWithdrawal">
|
||||
@(_isSubmittingWithdrawal ? "در حال ثبت..." : "ثبت درخواست برداشت")
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
}
|
||||
</MudPaper>
|
||||
|
||||
<!-- فیلتر وضعیت -->
|
||||
|
||||
@@ -6,12 +6,15 @@ namespace FrontOffice.Main.Pages.Profile;
|
||||
|
||||
public partial class WithdrawalRequests : ComponentBase
|
||||
{
|
||||
[Inject] private CommissionService CommissionService { get; set; } = default!;
|
||||
|
||||
private long _minWithdrawalAmount = 1_000_000;
|
||||
private List<WalletWithdrawal> _withdrawals = new();
|
||||
private List<CommissionPayoutDto> _availablePayouts = new();
|
||||
private string _statusFilter = "all";
|
||||
private bool _isLoading = true;
|
||||
private bool _isSubmittingWithdrawal;
|
||||
private long _withdrawPayoutId;
|
||||
private CommissionPayoutDto? _selectedPayout;
|
||||
private WithdrawalMethodClient _withdrawMethod = WithdrawalMethodClient.Cash;
|
||||
private string? _withdrawIban;
|
||||
|
||||
@@ -26,6 +29,7 @@ public partial class WithdrawalRequests : ComponentBase
|
||||
try
|
||||
{
|
||||
_withdrawals = await WalletService.GetWithdrawalsAsync();
|
||||
_availablePayouts = await CommissionService.GetWithdrawablePayoutsAsync();
|
||||
var settings = await WalletService.GetWithdrawalSettingsAsync();
|
||||
if (settings.MinWithdrawalAmount > 0)
|
||||
_minWithdrawalAmount = settings.MinWithdrawalAmount;
|
||||
@@ -40,9 +44,9 @@ public partial class WithdrawalRequests : ComponentBase
|
||||
|
||||
private async Task SubmitWithdrawal()
|
||||
{
|
||||
if (_withdrawPayoutId <= 0)
|
||||
if (_selectedPayout == null)
|
||||
{
|
||||
Snackbar.Add("شناسه واریز (PayoutId) الزامی است.", Severity.Warning);
|
||||
Snackbar.Add("لطفاً یک واریز را انتخاب کنید.", Severity.Warning);
|
||||
return;
|
||||
}
|
||||
if (_withdrawMethod == WithdrawalMethodClient.Cash && string.IsNullOrWhiteSpace(_withdrawIban))
|
||||
@@ -54,14 +58,14 @@ public partial class WithdrawalRequests : ComponentBase
|
||||
try
|
||||
{
|
||||
_isSubmittingWithdrawal = true;
|
||||
await WalletService.RequestWithdrawalAsync(_withdrawPayoutId, _withdrawMethod, _withdrawIban);
|
||||
await WalletService.RequestWithdrawalAsync(_selectedPayout.Id, _withdrawMethod, _withdrawIban);
|
||||
Snackbar.Add("درخواست برداشت ثبت شد.", Severity.Success);
|
||||
|
||||
// بروزرسانی لیست
|
||||
await LoadData();
|
||||
|
||||
// ریست فرم
|
||||
_withdrawPayoutId = 0;
|
||||
_selectedPayout = null;
|
||||
_withdrawIban = null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Reference in New Issue
Block a user