feat: Implement Commission and Network Statistics Pages with DTOs and Services
- Added CommissionDashboardPage and CommissionHistoryPage for displaying commission payouts and history. - Implemented WeeklyBalancePage to show weekly balance details. - Created NetworkStatisticsPage to display network statistics and tree structure. - Developed corresponding services (CommissionService, NetworkMembershipService) for data retrieval. - Introduced DTOs for Commission and Network data structures (CommissionPayoutDto, WeeklyBalanceDto, NetworkStatisticsDto). - Added mock data generation for testing purposes in services. - Enhanced UI with MudBlazor components for better user experience.
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
using FrontOffice.Main.Utilities;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace FrontOffice.Main.Pages.Commission;
|
||||
|
||||
public partial class CommissionDashboardPage : ComponentBase
|
||||
{
|
||||
[Inject] private CommissionService CommissionService { get; set; } = default!;
|
||||
|
||||
private List<CommissionPayoutDto> _payouts = new();
|
||||
private int _totalCount;
|
||||
private int _pageNumber = 1;
|
||||
private int _pageSize = 10;
|
||||
private bool _isLoading = true;
|
||||
|
||||
private int? _filterWeekNumber;
|
||||
private string _filterStatus = string.Empty;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await LoadPayoutsAsync();
|
||||
}
|
||||
|
||||
private async Task LoadPayoutsAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
_isLoading = true;
|
||||
var result = await CommissionService.GetMyCommissionPayoutsAsync(
|
||||
_filterWeekNumber,
|
||||
_filterStatus,
|
||||
_pageNumber,
|
||||
_pageSize
|
||||
);
|
||||
_payouts = result.Payouts;
|
||||
_totalCount = result.TotalCount;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا در دریافت کمیسیونها: {ex.Message}", Severity.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ApplyFiltersAsync()
|
||||
{
|
||||
_pageNumber = 1;
|
||||
await LoadPayoutsAsync();
|
||||
}
|
||||
|
||||
private async Task ClearFiltersAsync()
|
||||
{
|
||||
_filterWeekNumber = null;
|
||||
_filterStatus = string.Empty;
|
||||
_pageNumber = 1;
|
||||
await LoadPayoutsAsync();
|
||||
}
|
||||
|
||||
private async Task OnPageChangedAsync(int page)
|
||||
{
|
||||
_pageNumber = page;
|
||||
await LoadPayoutsAsync();
|
||||
}
|
||||
|
||||
private int GetTotalPages()
|
||||
{
|
||||
if (_totalCount == 0 || _pageSize == 0)
|
||||
return 1;
|
||||
return (int)Math.Ceiling(_totalCount / (double)_pageSize);
|
||||
}
|
||||
|
||||
private Color GetStatusColor(string statusColor) => statusColor.ToLower() switch
|
||||
{
|
||||
"success" => Color.Success,
|
||||
"warning" => Color.Warning,
|
||||
"error" => Color.Error,
|
||||
"info" => Color.Info,
|
||||
_ => Color.Default
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user