feat: update commission status handling and UI; enhance status representation with computed properties and improve filtering logic
Build and Deploy / build (push) Successful in 2m20s

This commit is contained in:
masoodafar-web
2025-12-27 07:31:31 +03:30
parent e3521af071
commit 3fdaa2c22a
6 changed files with 48 additions and 23 deletions
@@ -13,9 +13,31 @@ public class CommissionPayoutDto
public int BalancesEarned { get; set; }
public long TotalAmount { get; set; }
public string AmountFormatted { get; set; } = string.Empty;
public string Status { get; set; } = string.Empty;
public string StatusBadgeColor { get; set; } = string.Empty;
public int Status { get; set; }
public string DatePersian { get; set; } = string.Empty;
// Computed properties for UI
public string StatusText => Status switch
{
0 => "در انتظار",
1 => "پرداخت شده",
2 => "درخواست برداشت",
3 => "برداشت شده",
4 => "شکست خورده",
5 => "لغو شده",
_ => "نامشخص"
};
public string StatusColor => Status switch
{
0 => "warning",
1 => "success",
2 => "info",
3 => "success",
4 => "error",
5 => "default",
_ => "default"
};
}
/// <summary>
@@ -98,10 +98,12 @@ public class CommissionService
{
request.Status = status switch
{
"Pending" or "ایجاد شده" => 0,
"Calculated" or "محاسبه شده" => 1,
"Paid" or "پرداخت شده" => 2,
"Pending" or "در انتظار" or "Created" or "ایجاد شده" => 0,
"Paid" or "پرداخت شده" => 1,
"WithdrawalRequested" or "درخواست برداشت" => 2,
"Withdrawn" or "برداشت شده" => 3,
"PaymentFailed" or "شکست خورده" => 4,
"Cancelled" or "لغو شده" => 5,
_ => null
};
}
@@ -119,7 +121,6 @@ public class CommissionService
TotalAmount = p.TotalAmount,
AmountFormatted = p.AmountFormatted,
Status = p.Status,
StatusBadgeColor = p.StatusBadgeColor,
DatePersian = p.DatePersian
}).ToList(),
TotalCount = (int)(response.MetaData?.TotalCount ?? 0),
@@ -209,9 +210,9 @@ public class CommissionService
var response = await _client.GetMyCommissionPayoutsAsync(request);
// Filter: exclude already withdrawn (status text contains "برداشت" or status=3)
// Filter: exclude already withdrawn (status=3) and withdrawal requested (status=2)
return response.Payouts
.Where(p => !p.Status.Contains("برداشت") && p.Status != "Withdrawn")
.Where(p => p.Status != 2 && p.Status != 3)
.Select(p => new CommissionPayoutDto
{
Id = p.Id,
@@ -221,7 +222,6 @@ public class CommissionService
TotalAmount = p.TotalAmount,
AmountFormatted = p.AmountFormatted,
Status = p.Status,
StatusBadgeColor = p.StatusBadgeColor,
DatePersian = p.DatePersian
}).ToList();
}