diff --git a/apps/web-client-tpos-net/src/WebClientTpos.Client/Pages/Admin/Shop/ShopPage.razor b/apps/web-client-tpos-net/src/WebClientTpos.Client/Pages/Admin/Shop/ShopPage.razor index 3ecd45bf..28994b89 100644 --- a/apps/web-client-tpos-net/src/WebClientTpos.Client/Pages/Admin/Shop/ShopPage.razor +++ b/apps/web-client-tpos-net/src/WebClientTpos.Client/Pages/Admin/Shop/ShopPage.razor @@ -252,7 +252,7 @@ break; case "settings": - + 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); } diff --git a/apps/web-client-tpos-net/src/WebClientTpos.Client/Pages/Admin/Shop/ShopSettings.razor b/apps/web-client-tpos-net/src/WebClientTpos.Client/Pages/Admin/Shop/ShopSettings.razor index d6a679ab..f7e835cd 100644 --- a/apps/web-client-tpos-net/src/WebClientTpos.Client/Pages/Admin/Shop/ShopSettings.razor +++ b/apps/web-client-tpos-net/src/WebClientTpos.Client/Pages/Admin/Shop/ShopSettings.razor @@ -78,6 +78,45 @@ } +@* ─── 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)) +{ + + + + + + Kích hoạt cửa hàng + + + 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. + + + + Thông tin cửa hàng + + + Thiết lập giờ mở cửa + + + Tính năng cửa hàng + + + + + @if (_isPublishing) + { + + } + Kích hoạt ngay + + + +} + @* ─── 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) ─── *@ @@ -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; + /// + /// 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. + /// + 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(); + } + } + /// /// 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. diff --git a/apps/web-client-tpos-net/src/WebClientTpos.Client/Services/ShopVerticalHelper.cs b/apps/web-client-tpos-net/src/WebClientTpos.Client/Services/ShopVerticalHelper.cs index 06256e11..71dc3a28 100644 --- a/apps/web-client-tpos-net/src/WebClientTpos.Client/Services/ShopVerticalHelper.cs +++ b/apps/web-client-tpos-net/src/WebClientTpos.Client/Services/ShopVerticalHelper.cs @@ -49,13 +49,13 @@ public static class ShopVerticalHelper /// 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" }; /// @@ -108,10 +108,10 @@ public static class ShopVerticalHelper /// 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 ?? "—" };