fix(web-client-tpos): auto-register merchant before shop creation
This commit is contained in:
@@ -312,8 +312,8 @@
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// EN: Create shop via Merchant Service API.
|
||||
/// VI: Tạo shop qua API Merchant Service.
|
||||
/// EN: Create shop via Merchant Service API — auto-registers merchant if needed.
|
||||
/// VI: Tạo shop qua API Merchant Service — tự đăng ký merchant nếu cần.
|
||||
/// </summary>
|
||||
private async Task CreateStore()
|
||||
{
|
||||
@@ -322,8 +322,28 @@
|
||||
_isCreating = true;
|
||||
StateHasChanged();
|
||||
|
||||
// EN: Map store type to API category
|
||||
// VI: Map loại cửa hàng sang category API
|
||||
// EN: Step 1 — Ensure merchant is registered (auto-register if not)
|
||||
// VI: Bước 1 — Đảm bảo đã đăng ký merchant (tự đăng ký nếu chưa)
|
||||
var merchantDto = new MerchantRegisterDto
|
||||
{
|
||||
BusinessName = _storeName,
|
||||
Type = "Individual"
|
||||
};
|
||||
var (merchantResult, merchantError) = await MerchantApi.RegisterMerchantAsync(merchantDto);
|
||||
|
||||
// EN: 409 Conflict means already registered — that's OK, proceed
|
||||
// VI: 409 Conflict nghĩa là đã đăng ký rồi — OK, tiếp tục
|
||||
if (merchantResult == null && merchantError != null
|
||||
&& !merchantError.Contains("already has", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_errorMessage = $"Đăng ký merchant thất bại: {merchantError}";
|
||||
_isCreating = false;
|
||||
StateHasChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
// EN: Step 2 — Create the shop
|
||||
// VI: Bước 2 — Tạo cửa hàng
|
||||
var category = _selectedType switch
|
||||
{
|
||||
"cafe" => "FoodBeverage",
|
||||
|
||||
@@ -149,8 +149,8 @@ public class Merchant : Entity, IAggregateRoot
|
||||
_businessName = businessName.Trim(),
|
||||
_type = type,
|
||||
TypeId = type.Id,
|
||||
_status = MerchantStatus.PendingApproval,
|
||||
StatusId = MerchantStatus.PendingApproval.Id,
|
||||
_status = MerchantStatus.Active, // EN: Auto-activate for MVP dev flow / VI: Tự kích hoạt cho MVP dev
|
||||
StatusId = MerchantStatus.Active.Id,
|
||||
_verificationStatus = VerificationStatus.Unverified,
|
||||
VerificationStatusId = VerificationStatus.Unverified.Id,
|
||||
_businessInfo = BusinessInfo.Empty,
|
||||
|
||||
Reference in New Issue
Block a user