fix(ui): fix vertical/status labels and add shop activation button
- ShopVerticalHelper.GetLabel: return Vietnamese text directly instead of localization keys (Vertical_Cafe → Café, etc.) - ShopVerticalHelper.GetStatusLabel: return Vietnamese text directly (Status_Setup → Thiết lập, Status_Active → Đang mở, etc.) - ShopSettings: add "Kích hoạt cửa hàng" section with publish button when shop is in Draft status, with setup checklist indicators - ShopPage: pass ShopStatus parameter to ShopSettings component Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -252,7 +252,7 @@
|
||||
break;
|
||||
|
||||
case "settings":
|
||||
<ShopSettings ShopId="@(_shopGuid ?? Guid.Empty)" ShopName="@_shopName" VerticalLabel="@_verticalLabel" />
|
||||
<ShopSettings ShopId="@(_shopGuid ?? Guid.Empty)" ShopName="@_shopName" VerticalLabel="@_verticalLabel" ShopStatus="@_shopStatus" />
|
||||
break;
|
||||
|
||||
case "schedule":
|
||||
@@ -370,6 +370,7 @@
|
||||
|
||||
private string _shopName = "";
|
||||
private string _verticalLabel = "";
|
||||
private string? _shopStatus;
|
||||
private string _section = "";
|
||||
private string _sectionTitle = "";
|
||||
private string _sectionIcon = "layout-dashboard";
|
||||
@@ -430,6 +431,7 @@
|
||||
{
|
||||
_shopName = shop.Name ?? "Cửa hàng";
|
||||
_verticalLabel = ShopSidebarConfig.GetVerticalLabel(shop.Category);
|
||||
_shopStatus = shop.Status;
|
||||
_posVertical = MapCategoryToVertical(shop.Category);
|
||||
AdminLayoutRef?.SetShopContext(ShopId, _shopName, shop.Category);
|
||||
}
|
||||
|
||||
@@ -78,6 +78,45 @@
|
||||
}
|
||||
</div>
|
||||
|
||||
@* ─── EN: Publish / Activate shop (when Draft) ─── *@
|
||||
@* ─── VI: Kích hoạt cửa hàng (khi đang ở trạng thái Draft) ─── *@
|
||||
@if (ShopVerticalHelper.IsSetup(ShopStatus))
|
||||
{
|
||||
<MudPaper Class="mt-4 pa-0" Style="border: 1px solid rgba(34,197,94,0.4); border-radius: 8px; background: rgba(34,197,94,0.04); overflow: hidden;">
|
||||
<div style="padding: 20px; display: flex; align-items: center; justify-content: space-between;">
|
||||
<div>
|
||||
<MudText Typo="Typo.h6" Style="color: #22C55E; font-size: 16px; font-weight: 700;">
|
||||
<i data-lucide="rocket" style="width:18px;height:18px;display:inline;vertical-align:middle;margin-right:6px;"></i>
|
||||
Kích hoạt cửa hàng
|
||||
</MudText>
|
||||
<MudText Typo="Typo.body2" Style="color: var(--admin-text-tertiary, #999); font-size: 13px; margin-top: 4px;">
|
||||
Cửa hàng đang ở chế độ thiết lập. Kích hoạt để bắt đầu sử dụng POS bán hàng và nhận đơn hàng.
|
||||
</MudText>
|
||||
<div style="margin-top:8px;font-size:12px;color:var(--admin-text-tertiary);">
|
||||
<span style="display:inline-flex;align-items:center;gap:4px;margin-right:12px;">
|
||||
<i data-lucide="check-circle" style="width:12px;height:12px;color:#22C55E;"></i> Thông tin cửa hàng
|
||||
</span>
|
||||
<span style="display:inline-flex;align-items:center;gap:4px;margin-right:12px;">
|
||||
<i data-lucide="check-circle" style="width:12px;height:12px;color:#22C55E;"></i> Thiết lập giờ mở cửa
|
||||
</span>
|
||||
<span style="display:inline-flex;align-items:center;gap:4px;">
|
||||
<i data-lucide="check-circle" style="width:12px;height:12px;color:#22C55E;"></i> Tính năng cửa hàng
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Success" Size="Size.Medium"
|
||||
OnClick="OnPublishShop" Disabled="_isPublishing"
|
||||
Style="min-width: 160px; text-transform: none; font-weight: 700;">
|
||||
@if (_isPublishing)
|
||||
{
|
||||
<MudProgressCircular Size="Size.Small" Indeterminate="true" Class="mr-2" Style="width:16px;height:16px;" />
|
||||
}
|
||||
Kích hoạt ngay
|
||||
</MudButton>
|
||||
</div>
|
||||
</MudPaper>
|
||||
}
|
||||
|
||||
@* ─── EN: Danger Zone — shop lifecycle actions (deactivate, close) ─── *@
|
||||
@* ─── VI: Vùng nguy hiểm — thao tác vòng đời cửa hàng (tạm ngưng, đóng) ─── *@
|
||||
<MudPaper Class="mt-6 pa-0" Style="border: 1px solid #f44336; border-radius: 8px; background: rgba(244,67,54,0.04); overflow: hidden;">
|
||||
@@ -130,6 +169,7 @@
|
||||
[Parameter] public Guid ShopId { get; set; }
|
||||
[Parameter] public string? ShopName { get; set; }
|
||||
[Parameter] public string? VerticalLabel { get; set; }
|
||||
[Parameter] public string? ShopStatus { get; set; }
|
||||
|
||||
// Settings state
|
||||
private PosDataService.ShopSettingsInfo? _shopSettings;
|
||||
@@ -202,11 +242,49 @@
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
// EN: Publish state
|
||||
// VI: Trạng thái kích hoạt
|
||||
private bool _isPublishing;
|
||||
|
||||
// EN: Danger Zone state
|
||||
// VI: Trạng thái Vùng nguy hiểm
|
||||
private bool _isDangerActionRunning;
|
||||
private string? _dangerAction;
|
||||
|
||||
/// <summary>
|
||||
/// EN: Publish shop (Draft → Active). No confirmation needed.
|
||||
/// VI: Kích hoạt cửa hàng (Draft → Active). Không cần xác nhận.
|
||||
/// </summary>
|
||||
private async Task OnPublishShop()
|
||||
{
|
||||
if (ShopId == Guid.Empty) return;
|
||||
_isPublishing = true;
|
||||
StateHasChanged();
|
||||
try
|
||||
{
|
||||
var ok = await DataService.PublishShopAsync(ShopId);
|
||||
if (ok)
|
||||
{
|
||||
Snackbar.Add("Cửa hàng đã được kích hoạt thành công!", Severity.Success);
|
||||
ShopStatus = "Published";
|
||||
StateHasChanged();
|
||||
}
|
||||
else
|
||||
{
|
||||
Snackbar.Add("Không thể kích hoạt cửa hàng. Vui lòng thử lại.", Severity.Error);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"Lỗi: {ex.Message}", Severity.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isPublishing = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// EN: Show deactivate confirmation dialog and call API.
|
||||
/// VI: Hiển thị dialog xác nhận tạm ngưng và gọi API.
|
||||
|
||||
@@ -49,13 +49,13 @@ public static class ShopVerticalHelper
|
||||
/// </summary>
|
||||
public static string GetLabel(string? category) => NormalizeVertical(category) switch
|
||||
{
|
||||
"cafe" => "Vertical_Cafe",
|
||||
"restaurant" => "Vertical_Restaurant",
|
||||
"karaoke" => "Vertical_Karaoke",
|
||||
"spa" => "Vertical_Spa",
|
||||
"beauty" => "Vertical_Beauty",
|
||||
"retail" => "Vertical_Retail",
|
||||
_ => "Vertical_Store"
|
||||
"cafe" => "Café",
|
||||
"restaurant" => "Nhà hàng / Bar",
|
||||
"karaoke" => "Karaoke",
|
||||
"spa" => "Spa & Wellness",
|
||||
"beauty" => "Thẩm mỹ viện",
|
||||
"retail" => "Bán lẻ",
|
||||
_ => "Cửa hàng"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@@ -108,10 +108,10 @@ public static class ShopVerticalHelper
|
||||
/// </summary>
|
||||
public static string GetStatusLabel(string? status) => status?.ToLowerInvariant() switch
|
||||
{
|
||||
"published" or "active" => "Status_Active",
|
||||
"draft" or "setup" => "Status_Setup",
|
||||
"inactive" or "paused" => "Status_Paused",
|
||||
"closed" => "Status_Closed",
|
||||
"published" or "active" => "Đang mở",
|
||||
"draft" or "setup" => "Thiết lập",
|
||||
"inactive" or "paused" => "Tạm dừng",
|
||||
"closed" => "Đã đóng",
|
||||
_ => status ?? "—"
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user