From 598193e6cb9555b56bbf847b8739ebacf1c61138 Mon Sep 17 00:00:00 2001 From: Ho Ngoc Hai Date: Fri, 13 Mar 2026 15:30:12 +0700 Subject: [PATCH] fix: wire up admin attendance page to real API, add BFF shop attendance endpoint - BFF: add GET /api/bff/shops/{shopId}/attendance proxy to merchant-service - ShopAttendance.razor: replace mock data with real attendance API call - Calculate present/late/absent counts from actual attendance records Co-Authored-By: Claude Opus 4.6 --- .../Pages/Admin/Shop/ShopAttendance.razor | 15 +++++++++++---- .../Controllers/StaffController.cs | 11 +++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/apps/web-client-tpos-net/src/WebClientTpos.Client/Pages/Admin/Shop/ShopAttendance.razor b/apps/web-client-tpos-net/src/WebClientTpos.Client/Pages/Admin/Shop/ShopAttendance.razor index 0315153a..77281261 100644 --- a/apps/web-client-tpos-net/src/WebClientTpos.Client/Pages/Admin/Shop/ShopAttendance.razor +++ b/apps/web-client-tpos-net/src/WebClientTpos.Client/Pages/Admin/Shop/ShopAttendance.razor @@ -124,10 +124,17 @@ { var staff = await DataService.GetStaffForShopAsync(shopGuid); _staffCount = staff.Count; - // EN: Mock attendance for now — will proxy to real API - // VI: Mock chấm công tạm thời — sẽ proxy đến API thực - _records = new(); - _presentToday = staff.Count; + + // EN: Load real attendance data from merchant-service via BFF. + // VI: Tải dữ liệu chấm công thực từ merchant-service qua BFF. + var attendance = await DataService.GetListFromApiAsync( + $"api/bff/shops/{shopGuid}/attendance?month={_month}&year={_year}"); + _records = attendance; + + var today = DateTime.UtcNow.Date; + _presentToday = attendance.Count(a => a.Date.Date == today); + _lateCount = attendance.Count(a => a.Date.Date == today && a.CheckIn.HasValue && a.CheckIn.Value.Hour >= 9); + _absentCount = _staffCount - _presentToday; } } catch { } diff --git a/apps/web-client-tpos-net/src/WebClientTpos.Server/Controllers/StaffController.cs b/apps/web-client-tpos-net/src/WebClientTpos.Server/Controllers/StaffController.cs index 9ec897f1..bd7c5340 100644 --- a/apps/web-client-tpos-net/src/WebClientTpos.Server/Controllers/StaffController.cs +++ b/apps/web-client-tpos-net/src/WebClientTpos.Server/Controllers/StaffController.cs @@ -414,6 +414,17 @@ public class StaffController : ControllerBase return await _merchant.PostAsJsonAsync("/api/v1/attendance/check-out", payload).ProxyAsync(); } + /// + /// EN: Get attendance records for a shop (admin) — proxies to merchant-service. + /// VI: Lấy bản ghi chấm công theo shop (admin) — proxy đến merchant-service. + /// + [HttpGet("shops/{shopId:guid}/attendance")] + public Task GetShopAttendance(Guid shopId, [FromQuery] int month = 0, [FromQuery] int year = 0) + { + var qs = $"?month={month}&year={year}"; + return _merchant.GetAsync($"/api/v1/attendance/shop/{shopId}{qs}").ProxyAsync(); + } + /// /// EN: Get all available staff roles. /// VI: Lấy tất cả vai trò nhân viên hiện có.