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,82 @@
|
||||
using FrontOffice.Main.Utilities;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace FrontOffice.Main.Pages.Commission;
|
||||
|
||||
public partial class WeeklyBalancePage : ComponentBase
|
||||
{
|
||||
[Inject] private CommissionService CommissionService { get; set; } = default!;
|
||||
|
||||
[Parameter]
|
||||
[SupplyParameterFromQuery(Name = "week")]
|
||||
public int? QueryWeekNumber { get; set; }
|
||||
|
||||
private WeeklyBalanceDto? _weeklyBalance;
|
||||
private int? _selectedWeekNumber;
|
||||
private bool _isLoading = true;
|
||||
private bool _hasError = false;
|
||||
|
||||
private readonly ChartOptions _chartOptions = new()
|
||||
{
|
||||
ChartPalette = new[]
|
||||
{
|
||||
"#2196F3", // Info (Left)
|
||||
"#4CAF50", // Success (Right)
|
||||
"#FF9800" // Warning (Min)
|
||||
}
|
||||
};
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (QueryWeekNumber.HasValue)
|
||||
_selectedWeekNumber = QueryWeekNumber;
|
||||
|
||||
await LoadWeeklyBalanceAsync();
|
||||
}
|
||||
|
||||
private async Task LoadWeeklyBalanceAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
_isLoading = true;
|
||||
_hasError = false;
|
||||
_weeklyBalance = await CommissionService.GetMyWeeklyBalanceAsync(_selectedWeekNumber);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_hasError = true;
|
||||
Snackbar.Add($"خطا در دریافت تعادل: {ex.Message}", Severity.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task LoadCurrentWeekAsync()
|
||||
{
|
||||
_selectedWeekNumber = null;
|
||||
await LoadWeeklyBalanceAsync();
|
||||
}
|
||||
|
||||
private double GetLeftPercentage()
|
||||
{
|
||||
if (_weeklyBalance is null)
|
||||
return 0;
|
||||
var total = _weeklyBalance.LeftBalance + _weeklyBalance.RightBalance;
|
||||
if (total == 0)
|
||||
return 0;
|
||||
return (_weeklyBalance.LeftBalance / (double)total) * 100;
|
||||
}
|
||||
|
||||
private double GetRightPercentage()
|
||||
{
|
||||
if (_weeklyBalance is null)
|
||||
return 0;
|
||||
var total = _weeklyBalance.LeftBalance + _weeklyBalance.RightBalance;
|
||||
if (total == 0)
|
||||
return 0;
|
||||
return (_weeklyBalance.RightBalance / (double)total) * 100;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user