From 9f8bdfd9d3b0ae97cd4feab65a57a859cf7b23dd Mon Sep 17 00:00:00 2001 From: Ho Ngoc Hai Date: Mon, 30 Mar 2026 11:06:18 +0700 Subject: [PATCH] fix(staff): include employeeCode, phone, address in IAM staff creation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BFF InviteStaffWithAccount endpoint was constructing payload for merchant-service without employeeCode, phone, and address fields. This caused these fields to be null for all staff created via IAM account flow — the edit form then showed empty Mã NV. - Add employeeCode, phone, address to both create-active and invite payloads in BFF StaffController - Add optional EmployeeCode, Phone, Address params to InviteStaffWithAccountRequest DTO - Pass _newStaffCode, _newStaffPhone, _newStaffAddress from ShopStaff.razor when creating via IAM flow Co-Authored-By: Claude Opus 4.6 (1M context) --- .../Pages/Admin/Shop/ShopStaff.razor | 3 ++- .../WebClientTpos.Client/Services/PosDataService.cs | 3 ++- .../Controllers/StaffController.cs | 10 ++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/web-client-tpos-net/src/WebClientTpos.Client/Pages/Admin/Shop/ShopStaff.razor b/apps/web-client-tpos-net/src/WebClientTpos.Client/Pages/Admin/Shop/ShopStaff.razor index 7cd673cb..efe5aa5c 100644 --- a/apps/web-client-tpos-net/src/WebClientTpos.Client/Pages/Admin/Shop/ShopStaff.razor +++ b/apps/web-client-tpos-net/src/WebClientTpos.Client/Pages/Admin/Shop/ShopStaff.razor @@ -208,7 +208,8 @@ else if (_staff.Any()) _staffFormMessage = "Vui lòng nhập đầy đủ email và mật khẩu."; _staffFormSuccess = false; return; } var (ok, err) = await DataService.InviteStaffWithAccountAsync(new PosDataService.InviteStaffWithAccountRequest( - _newStaffEmail, _newStaffPassword, _newStaffFirstName, _newStaffLastName, _newStaffRole, ShopId)); + _newStaffEmail, _newStaffPassword, _newStaffFirstName, _newStaffLastName, _newStaffRole, ShopId, + _newStaffCode, _newStaffPhone, _newStaffAddress)); if (!ok) { _staffFormMessage = err ?? "Lỗi tạo tài khoản IAM. Kiểm tra email/mật khẩu."; _staffFormSuccess = false; return; } _staffFormMessage = $"Đã tạo tài khoản + mời NV '{_newStaffEmail}' thành công!"; _staffFormSuccess = true; } diff --git a/apps/web-client-tpos-net/src/WebClientTpos.Client/Services/PosDataService.cs b/apps/web-client-tpos-net/src/WebClientTpos.Client/Services/PosDataService.cs index 73de71dc..467e8fa1 100644 --- a/apps/web-client-tpos-net/src/WebClientTpos.Client/Services/PosDataService.cs +++ b/apps/web-client-tpos-net/src/WebClientTpos.Client/Services/PosDataService.cs @@ -1181,7 +1181,8 @@ public class PosDataService // ═══ STAFF IAM ═══ - public record InviteStaffWithAccountRequest(string Email, string Password, string FirstName, string LastName, string Role, Guid? ShopId); + public record InviteStaffWithAccountRequest(string Email, string Password, string FirstName, string LastName, string Role, Guid? ShopId, + string? EmployeeCode = null, string? Phone = null, string? Address = null); public async Task<(bool Ok, string? Error)> InviteStaffWithAccountAsync(InviteStaffWithAccountRequest req) { 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 af3bbeb4..e1b718a0 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 @@ -105,7 +105,10 @@ public class StaffController : ControllerBase role = body.TryGetProperty("role", out var r1) ? r1.GetString() : "Cashier", shopId = body.TryGetProperty("shopId", out var s1) ? s1.GetString() : null as string, firstName = iamPayload.firstName, - lastName = iamPayload.lastName + lastName = iamPayload.lastName, + employeeCode = body.TryGetProperty("employeeCode", out var ec1) ? ec1.GetString() : null as string, + phone = body.TryGetProperty("phone", out var ph1) ? ph1.GetString() : null as string, + address = body.TryGetProperty("address", out var ad1) ? ad1.GetString() : null as string }; return await _merchant.PostAsJsonAsync("/api/v1/merchants/me/staff/create-active", createPayload).ProxyAsync(); } @@ -118,7 +121,10 @@ public class StaffController : ControllerBase role = body.TryGetProperty("role", out var r2) ? r2.GetString() : "Cashier", shopId = body.TryGetProperty("shopId", out var s2) ? s2.GetString() : null as string, firstName = iamPayload.firstName, - lastName = iamPayload.lastName + lastName = iamPayload.lastName, + employeeCode = body.TryGetProperty("employeeCode", out var ec2) ? ec2.GetString() : null as string, + phone = body.TryGetProperty("phone", out var ph2) ? ph2.GetString() : null as string, + address = body.TryGetProperty("address", out var ad2) ? ad2.GetString() : null as string }; return await _merchant.PostAsJsonAsync("/api/v1/merchants/me/staff/invite", invitePayload).ProxyAsync(); }