fix(ui): translate order status and payment method to Vietnamese

- ShopHelpers: add OrderStatusLabel(), OrderStatusBadge(),
  PaymentMethodLabel() — translate raw status/method strings
  to Vietnamese with correct badge colors
- ShopFinance.razor: "Validated" → "Chờ thanh toán" (yellow badge)
- ShopOverview.razor: same status translation
- ShopReports.razor: same status translation
- CafeDesktop.razor: update MapApiStatus() to include
  Draft/Validated/Paid/PaymentPending mappings;
  update MapPaymentMethodLabel() to include qr→"Mã QR",
  transfer→"Chuyển khoản", vnpay/momo, empty→"Chưa thanh toán"

4 payment methods supported: Tiền mặt, Thẻ, Mã QR, Chuyển khoản

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ho Ngoc Hai
2026-03-26 09:56:14 +07:00
parent 2d738aeefa
commit c708bda364
5 changed files with 55 additions and 7 deletions

View File

@@ -72,7 +72,7 @@
<tr style="border-top:1px solid var(--admin-border-subtle);cursor:pointer;@(isOrderExpanded ? "background:rgba(255,92,0,0.05);" : "")" @onclick="@(() => ViewOrderDetail(o.Id))">
<td style="padding:12px 16px;font-size:12px;font-family:monospace;color:var(--admin-text-tertiary);">@o.Id.ToString()[..8]</td>
<td style="padding:12px 16px;text-align:right;font-weight:600;">@ShopHelpers.FormatVND(o.TotalAmount)</td>
<td style="padding:12px 16px;text-align:center;"><span class="admin-status-badge admin-status-badge--online" style="font-size:11px;padding:2px 10px;">@(o.Status ?? "—")</span></td>
<td style="padding:12px 16px;text-align:center;"><span class="admin-status-badge admin-status-badge--@ShopHelpers.OrderStatusBadge(o.Status)" style="font-size:11px;padding:2px 10px;">@ShopHelpers.OrderStatusLabel(o.Status)</span></td>
<td style="padding:12px 16px;font-size:13px;color:var(--admin-text-tertiary);">@o.CreatedAt.ToString("dd/MM HH:mm")</td>
<td style="padding:12px 16px;text-align:center;"><i data-lucide="@(isOrderExpanded ? "chevron-up" : "chevron-down")" style="width:14px;height:14px;color:var(--admin-text-tertiary);"></i></td>
</tr>

View File

@@ -27,4 +27,47 @@ public static class ShopHelpers
public static string FormatFileSize(long b) => b < 1024 ? $"{b} B" : b < 1048576 ? $"{b / 1024.0:F1} KB" : b < 1073741824 ? $"{b / 1048576.0:F1} MB" : $"{b / 1073741824.0:F2} GB";
public static string GetFileIcon(string? ct) => ct switch { string s when s.StartsWith("image/") => "image", string s when s.StartsWith("video/") => "video", string s when s.Contains("pdf") => "file-text", _ => "file" };
/// <summary>
/// EN: Translate order status to Vietnamese.
/// VI: Dịch trạng thái đơn hàng sang tiếng Việt.
/// </summary>
public static string OrderStatusLabel(string? status) => status?.ToLowerInvariant() switch
{
"draft" => "Nháp",
"validated" => "Chờ thanh toán",
"paid" => "Đã thanh toán",
"processing" => "Đang xử lý",
"completed" => "Hoàn thành",
"cancelled" => "Đã hủy",
"paymentpending" => "Chờ xác nhận TT",
_ => status ?? "—"
};
/// <summary>
/// EN: Get CSS badge class for order status.
/// VI: Lấy CSS badge class cho trạng thái đơn hàng.
/// </summary>
public static string OrderStatusBadge(string? status) => status?.ToLowerInvariant() switch
{
"completed" or "paid" => "online",
"validated" or "processing" or "paymentpending" => "setup",
"cancelled" => "paused",
_ => "setup"
};
/// <summary>
/// EN: Translate payment method to Vietnamese.
/// VI: Dịch hình thức thanh toán sang tiếng Việt.
/// </summary>
public static string PaymentMethodLabel(string? method) => method?.ToLowerInvariant() switch
{
"cash" => "Tiền mặt",
"card" => "Thẻ",
"qr" => "Mã QR",
"transfer" or "bank_transfer" => "Chuyển khoản",
"vnpay" => "VNPay",
"momo" => "MoMo",
_ => string.IsNullOrEmpty(method) ? "Chưa thanh toán" : method
};
}

View File

@@ -220,7 +220,7 @@
<span style="font-size:11px;color:var(--admin-text-tertiary);">@o.CreatedAt.ToString("dd/MM HH:mm")</span>
</div>
<div style="display:flex;align-items:center;gap:8px;">
<span class="admin-status-badge admin-status-badge--online" style="font-size:10px;padding:2px 8px;"><span class="admin-status-badge__dot" style="width:4px;height:4px;"></span>@(o.Status ?? "—")</span>
<span class="admin-status-badge admin-status-badge--@ShopHelpers.OrderStatusBadge(o.Status)" style="font-size:10px;padding:2px 8px;"><span class="admin-status-badge__dot" style="width:4px;height:4px;"></span>@ShopHelpers.OrderStatusLabel(o.Status)</span>
<span style="font-weight:600;font-size:13px;">@FormatVND(o.TotalAmount)</span>
</div>
</div>

View File

@@ -153,7 +153,7 @@
<tr style="border-top:1px solid var(--admin-border-subtle);">
<td style="padding:12px 16px;font-family:monospace;font-size:12px;font-weight:600;">@o.Id.ToString()[..8]</td>
<td style="padding:12px 16px;text-align:right;font-weight:600;color:var(--admin-orange-primary);">@ShopHelpers.FormatVND(o.TotalAmount)</td>
<td style="padding:12px 16px;"><span class="admin-status-badge admin-status-badge--online" style="font-size:10px;"><span class="admin-status-badge__dot"></span>@(o.Status ?? "—")</span></td>
<td style="padding:12px 16px;"><span class="admin-status-badge admin-status-badge--@ShopHelpers.OrderStatusBadge(o.Status)" style="font-size:10px;"><span class="admin-status-badge__dot"></span>@ShopHelpers.OrderStatusLabel(o.Status)</span></td>
<td style="padding:12px 16px;font-size:13px;color:var(--admin-text-tertiary);">@o.CreatedAt.ToString("dd/MM/yyyy HH:mm")</td>
</tr>
}

View File

@@ -1121,11 +1121,14 @@
private static string MapApiStatus(string? status) => status switch
{
"Draft" => "Nháp",
"Validated" => "Chờ thanh toán",
"Paid" => "Đã thanh toán",
"Completed" or "Delivered" => "Hoàn thành",
"Cancelled" => "Đã hủy",
"Refunded" => "Hoàn trả",
"Processing" => "Đang xử lý",
"Pending" => "Chờ xác nhận",
"Pending" or "PaymentPending" => "Chờ xác nhận TT",
_ => status ?? "—"
};
@@ -1133,9 +1136,11 @@
{
"cash" => "Tiền mặt",
"card" => "Thẻ",
"qr" => "QR Code",
"bank_transfer" => "Chuyển khoản",
_ => method ?? "Tiền mặt"
"qr" => "Mã QR",
"transfer" or "bank_transfer" => "Chuyển khoản",
"vnpay" => "VNPay",
"momo" => "MoMo",
_ => string.IsNullOrEmpty(method) ? "Chưa thanh toán" : method
};
private async Task ViewOrderDetail(Guid orderId)