From c1bb68859eba267a36d1c96ad3ccdec091d1e4fc Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 27 Feb 2026 07:55:29 +0000 Subject: [PATCH] fix(admin): dashboard loads shops from BFF API, shows onboarding when empty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Inject PosDataService and load shops in OnInitializedAsync - Show 'Welcome! Tạo cửa hàng đầu tiên' with onboarding link when no shops - Render dynamic shop cards from DB data when shops exist - Keep existing KPI cards and alerts/activity panels unchanged Co-authored-by: Velik --- .../Pages/Admin/Dashboard.razor | 183 +++++++----------- 1 file changed, 70 insertions(+), 113 deletions(-) diff --git a/apps/web-client-tpos-net/src/WebClientTpos.Client/Pages/Admin/Dashboard.razor b/apps/web-client-tpos-net/src/WebClientTpos.Client/Pages/Admin/Dashboard.razor index 048eca92..16181cec 100644 --- a/apps/web-client-tpos-net/src/WebClientTpos.Client/Pages/Admin/Dashboard.razor +++ b/apps/web-client-tpos-net/src/WebClientTpos.Client/Pages/Admin/Dashboard.razor @@ -1,6 +1,8 @@ @page "/admin" @layout AdminLayout @inherits AdminBase +@inject PosDataService DataService +@using WebClientTpos.Client.Services @* EN: Admin Dashboard — overview of business metrics, stores, alerts, and recent activity. @@ -107,123 +109,47 @@ Cửa hàng của bạn - Quản lý tất cả → + @if (_shops.Count > 0) + { + Quản lý tất cả → + }
- @* Store 1: Coffee House Q1 *@ -
-
-
-
- -
-
-
Coffee House Q1
-
Café • 123 Nguyễn Huệ, Q1
+ @if (_shops.Count == 0) + { +
+ +

Welcome! Tạo cửa hàng đầu tiên

+

Bắt đầu bằng việc tạo cửa hàng để quản lý kinh doanh của bạn.

+ + + Tạo cửa hàng ngay + +
+ } + else + { + @foreach (var shop in _shops) + { +
+
+
+
+ +
+
+
@shop.Name
+
@(shop.Category ?? "Shop") • @(shop.Description ?? shop.Slug)
+
+
+
+ + @(shop.Status == "active" ? "Đang mở" : "Thiết lập") +
-
- - Đang mở -
-
-
-
-
45.2M
-
Doanh thu
-
-
-
342
-
Đơn hàng
-
-
-
5
-
Nhân viên
-
-
-
48
-
Sản phẩm
-
-
-
- - @* Store 2: Nhà hàng Q3 *@ -
-
-
-
- -
-
-
Nhà hàng Q3
-
Restaurant • 456 Lê Văn Sỹ, Q3
-
-
-
- - Đang mở -
-
-
-
-
62.8M
-
Doanh thu
-
-
-
185
-
Đơn hàng
-
-
-
8
-
Nhân viên
-
-
-
72
-
Sản phẩm
-
-
-
- - @* Store 3: Karaoke Star Q7 *@ -
-
-
-
- -
-
-
Karaoke Star Q7
-
Karaoke • 789 Nguyễn Thị Thập, Q7
-
-
-
- - Thiết lập -
-
-
-
-
--
-
Doanh thu
-
-
-
--
-
Đơn hàng
-
-
-
0
-
Nhân viên
-
-
-
0
-
Sản phẩm
-
-
- -
+ } + }
@@ -316,3 +242,34 @@
+ +@code { + private List _shops = new(); + + protected override async Task OnInitializedAsync() + { + IsLoading = true; + try + { + _shops = await DataService.GetShopsAsync(); + } + catch + { + _shops = new(); + } + finally + { + IsLoading = false; + } + } + + private static string GetShopIcon(string? category) => category?.ToLowerInvariant() switch + { + "cafe" or "café" or "coffee" => "coffee", + "restaurant" or "nhà hàng" => "utensils", + "karaoke" => "mic", + "spa" => "sparkles", + "retail" => "shopping-bag", + _ => "store" + }; +}