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)
|
||||
|
||||
@@ -3,37 +3,91 @@
|
||||
|
||||
<PageTitle>محصولات</PageTitle>
|
||||
|
||||
<MudContainer MaxWidth="MaxWidth.Large" Class="pa-2 pa-md-6 ">
|
||||
<MudPaper Elevation="1" Class="pa-4 mb-4 rounded-lg">
|
||||
<MudContainer MaxWidth="MaxWidth.Large" Class="pa-2 pa-md-6">
|
||||
<MudPaper Elevation="1" Class="pa-3 pa-md-4 mb-4 rounded-lg">
|
||||
<MudGrid Spacing="2" AlignItems="AlignItems.Center">
|
||||
<MudItem xs="12" md="8">
|
||||
@* ردیف اول: جستجو و دکمهها *@
|
||||
<MudItem xs="12" md="6">
|
||||
<MudTextField @bind-Value="_query"
|
||||
Placeholder="جستجو در محصولات..."
|
||||
AdornmentIcon="@Icons.Material.Filled.Search"
|
||||
Adornment="Adornment.Start"
|
||||
Immediate="true"
|
||||
OnKeyUp="OnQueryChanged"
|
||||
Class="w-100"/>
|
||||
Variant="Variant.Outlined"
|
||||
Margin="Margin.Dense"/>
|
||||
</MudItem>
|
||||
<MudItem xs="12" md="4" Class="d-flex justify-end flex-wrap gap-2">
|
||||
<MudButton Class="w-100-mobile" Variant="Variant.Outlined" Color="Color.Primary"
|
||||
StartIcon="@Icons.Material.Filled.ViewList" Href="@RouteConstants.Store.Categories">
|
||||
<MudItem xs="12" md="6" Class="d-flex justify-start justify-md-end gap-2">
|
||||
<MudButton Size="Size.Small" Variant="Variant.Outlined" Color="Color.Primary"
|
||||
StartIcon="@Icons.Material.Filled.Category" Href="@RouteConstants.Store.Categories">
|
||||
دستهبندیها
|
||||
</MudButton>
|
||||
<MudButton Class="w-100-mobile" Variant="Variant.Filled" Color="Color.Primary"
|
||||
<MudButton Size="Size.Small" Variant="Variant.Filled" Color="Color.Primary"
|
||||
StartIcon="@Icons.Material.Filled.ShoppingCart" Href="@RouteConstants.Store.Cart">
|
||||
سبد خرید (@Cart.Count)
|
||||
سبد خرید
|
||||
@if (Cart.Count > 0)
|
||||
{
|
||||
<MudBadge Content="@Cart.Count" Color="Color.Error" Overlap="true" Class="ms-2"/>
|
||||
}
|
||||
</MudButton>
|
||||
</MudItem>
|
||||
|
||||
@* ردیف دوم: فیلترها و مرتبسازی *@
|
||||
<MudItem xs="12">
|
||||
<MudDivider Class="my-2"/>
|
||||
</MudItem>
|
||||
<MudItem xs="6" sm="4" md="3">
|
||||
<MudSelect T="ProductSortOption" @bind-Value="_sortOption"
|
||||
@bind-Value:after="OnSortChanged"
|
||||
Label="مرتبسازی"
|
||||
Variant="Variant.Outlined"
|
||||
Margin="Margin.Dense"
|
||||
AnchorOrigin="Origin.BottomCenter"
|
||||
AdornmentIcon="@Icons.Material.Filled.Sort">
|
||||
<MudSelectItem Value="ProductSortOption.PriceDesc">
|
||||
<div class="d-flex align-center gap-2">
|
||||
<MudIcon Icon="@Icons.Material.Filled.ArrowDownward" Size="Size.Small"/>
|
||||
گرانترین
|
||||
</div>
|
||||
</MudSelectItem>
|
||||
<MudSelectItem Value="ProductSortOption.PriceAsc">
|
||||
<div class="d-flex align-center gap-2">
|
||||
<MudIcon Icon="@Icons.Material.Filled.ArrowUpward" Size="Size.Small"/>
|
||||
ارزانترین
|
||||
</div>
|
||||
</MudSelectItem>
|
||||
<MudSelectItem Value="ProductSortOption.Newest">
|
||||
<div class="d-flex align-center gap-2">
|
||||
<MudIcon Icon="@Icons.Material.Filled.NewReleases" Size="Size.Small"/>
|
||||
جدیدترین
|
||||
</div>
|
||||
</MudSelectItem>
|
||||
<MudSelectItem Value="ProductSortOption.Title">
|
||||
<div class="d-flex align-center gap-2">
|
||||
<MudIcon Icon="@Icons.Material.Filled.SortByAlpha" Size="Size.Small"/>
|
||||
الفبایی
|
||||
</div>
|
||||
</MudSelectItem>
|
||||
</MudSelect>
|
||||
</MudItem>
|
||||
<MudItem xs="6" sm="8" md="9" Class="d-flex align-center">
|
||||
@if (_activeCategoryId.HasValue)
|
||||
{
|
||||
<MudChip T="string" Color="Color.Info" Variant="Variant.Filled" Size="Size.Small"
|
||||
Icon="@Icons.Material.Filled.FilterAlt"
|
||||
Closeable="true" OnClose="ClearCategoryFilter">
|
||||
@(_activeCategoryTitle ?? $"دستهبندی #{_activeCategoryId}")
|
||||
</MudChip>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudText Typo="Typo.body2" Class="mud-text-secondary">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Inventory2" Size="Size.Small" Class="me-1"/>
|
||||
@(_products.Count) محصول
|
||||
</MudText>
|
||||
}
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
@if (_activeCategoryId.HasValue)
|
||||
{
|
||||
<MudStack Spacing="1" Class="mt-3">
|
||||
<MudChip T="string" Color="Color.Info" Variant="Variant.Filled" Closeable="true" OnClose="ClearCategoryFilter">
|
||||
@(_activeCategoryTitle ?? $"دستهبندی #{_activeCategoryId}")
|
||||
</MudChip>
|
||||
</MudStack>
|
||||
}
|
||||
</MudPaper>
|
||||
|
||||
@if (_loading)
|
||||
|
||||
@@ -7,6 +7,14 @@ using FrontOffice.Main.Utilities;
|
||||
|
||||
namespace FrontOffice.Main.Pages.Store;
|
||||
|
||||
public enum ProductSortOption
|
||||
{
|
||||
PriceDesc, // گرانترین (پیشفرض)
|
||||
PriceAsc, // ارزانترین
|
||||
Newest, // جدیدترین
|
||||
Title // الفبایی
|
||||
}
|
||||
|
||||
public partial class Products : ComponentBase, IDisposable
|
||||
{
|
||||
[Inject] private ProductService ProductService { get; set; } = default!;
|
||||
@@ -19,6 +27,8 @@ public partial class Products : ComponentBase, IDisposable
|
||||
private List<Product> _products = new();
|
||||
private long? _activeCategoryId;
|
||||
private string? _activeCategoryTitle;
|
||||
|
||||
private ProductSortOption _sortOption = ProductSortOption.PriceDesc; // پیشفرض: گرانترین
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
@@ -43,13 +53,31 @@ public partial class Products : ComponentBase, IDisposable
|
||||
{
|
||||
_loading = true;
|
||||
UpdateCategoryFilterFromUri();
|
||||
_products = await ProductService.GetProductsAsync(_query, _activeCategoryId);
|
||||
var sortBy = GetSortByValue();
|
||||
_products = await ProductService.GetProductsAsync(_query, _activeCategoryId, sortBy);
|
||||
_activeCategoryTitle = _activeCategoryId is { } categoryId
|
||||
? (await CategoryService.GetByIdAsync(categoryId))?.Title
|
||||
: null;
|
||||
_loading = false;
|
||||
}
|
||||
|
||||
private string GetSortByValue()
|
||||
{
|
||||
return _sortOption switch
|
||||
{
|
||||
ProductSortOption.PriceDesc => "price desc",
|
||||
ProductSortOption.PriceAsc => "price asc",
|
||||
ProductSortOption.Newest => "id desc",
|
||||
ProductSortOption.Title => "title asc",
|
||||
_ => "price desc"
|
||||
};
|
||||
}
|
||||
|
||||
private async Task OnSortChanged()
|
||||
{
|
||||
await Load();
|
||||
}
|
||||
|
||||
private async Task OnQueryChanged(KeyboardEventArgs _)
|
||||
{
|
||||
await Load();
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="fa">
|
||||
<html lang="fa" dir="rtl">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
Reference in New Issue
Block a user