fix(staff): include employeeCode, phone, address in IAM staff creation
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) <noreply@anthropic.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user