29ce8cad38
Build and Deploy / build (push) Successful in 1m22s
- Updated CommissionDashboardPage to reflect new terminology for rewards instead of commissions. - Removed CommissionHistoryPage as its functionality has been integrated into the dashboard. - Adjusted WeeklyBalancePage to align with new reward terminology and improved layout. - Modified Index, NetworkStatisticsPage, MyPackages, Packages, Profile, and Wallet pages to use consistent terms related to team and rewards. - Updated ClubMembershipContractDialog to clarify user invitation terms. - Enhanced footer description to reflect the focus on sales teams.
103 lines
2.7 KiB
C#
103 lines
2.7 KiB
C#
using FrontOffice.Main.Shared;
|
|
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 long _totalAmount;
|
|
private int _pageNumber = 1;
|
|
private int _pageSize = 10;
|
|
private bool _isLoading = true;
|
|
|
|
private WeekSelector? _weekSelector;
|
|
private WeekDefinitionDto? _selectedWeekDefinition;
|
|
private string _filterStatus = string.Empty;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await LoadPayoutsAsync();
|
|
}
|
|
|
|
private async Task LoadPayoutsAsync()
|
|
{
|
|
try
|
|
{
|
|
_isLoading = true;
|
|
var weekDefinitionId = _selectedWeekDefinition?.Id;
|
|
var result = await CommissionService.GetMyCommissionPayoutsAsync(
|
|
weekDefinitionId,
|
|
_filterStatus,
|
|
_pageNumber,
|
|
_pageSize
|
|
);
|
|
_payouts = result.Payouts;
|
|
_totalCount = result.TotalCount;
|
|
_totalAmount = _payouts.Sum(p => p.TotalAmount);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Snackbar.Add($"خطا در دریافت پاداشها: {ex.Message}", Severity.Error);
|
|
}
|
|
finally
|
|
{
|
|
_isLoading = false;
|
|
}
|
|
}
|
|
|
|
private async Task ApplyFiltersAsync()
|
|
{
|
|
_pageNumber = 1;
|
|
await LoadPayoutsAsync();
|
|
}
|
|
|
|
private async Task ClearFiltersAsync()
|
|
{
|
|
_selectedWeekDefinition = 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 string GetTotalEarnings()
|
|
{
|
|
return $"{_totalAmount:N0} تومان";
|
|
}
|
|
|
|
private string GetAverageWeekly()
|
|
{
|
|
if (_totalCount == 0)
|
|
return "0 تومان";
|
|
var avg = _totalAmount / _totalCount;
|
|
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
|
|
};
|
|
}
|