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,65 @@
|
||||
using FrontOffice.Main.Utilities;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace FrontOffice.Main.Pages.Commission;
|
||||
|
||||
public partial class CommissionHistoryPage : ComponentBase
|
||||
{
|
||||
[Inject] private CommissionService CommissionService { get; set; } = default!;
|
||||
|
||||
private List<CommissionPayoutDto> _payouts = new();
|
||||
private bool _isLoading = true;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await LoadAllPayoutsAsync();
|
||||
}
|
||||
|
||||
private async Task LoadAllPayoutsAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
_isLoading = true;
|
||||
// Load all payouts (large page size to get everything)
|
||||
var result = await CommissionService.GetMyCommissionPayoutsAsync(
|
||||
null,
|
||||
string.Empty,
|
||||
1,
|
||||
1000
|
||||
);
|
||||
_payouts = result.Payouts;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا در دریافت تاریخچه: {ex.Message}", Severity.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
private string GetTotalEarnings()
|
||||
{
|
||||
var total = _payouts.Sum(p => p.TotalAmount);
|
||||
return $"{total:N0} تومان";
|
||||
}
|
||||
|
||||
private string GetAverageWeekly()
|
||||
{
|
||||
if (!_payouts.Any())
|
||||
return "0 تومان";
|
||||
var avg = _payouts.Average(p => p.TotalAmount);
|
||||
return $"{avg:N0} تومان";
|
||||
}
|
||||
|
||||
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