forked from baron/baron-sso
동기화 기초구조 마련
This commit is contained in:
@@ -206,7 +206,10 @@ export function UserBulkUploadModal({ onSuccess }: UserBulkUploadModalProps) {
|
||||
|
||||
const resolveUserImportTenants = async () => {
|
||||
const tenants = tenantQuery.data?.items ?? [];
|
||||
const tenantSlugByKey = new Map<string, string>();
|
||||
const tenantByKey = new Map<
|
||||
string,
|
||||
{ id: string; slug: string; emailDomain: string }
|
||||
>();
|
||||
|
||||
for (const preview of tenantPreviewRows) {
|
||||
const key = tenantImportKeyFromRow(preview.row);
|
||||
@@ -215,7 +218,11 @@ export function UserBulkUploadModal({ onSuccess }: UserBulkUploadModalProps) {
|
||||
if (selected !== "__create__") {
|
||||
const tenant = tenants.find((item) => item.id === selected);
|
||||
if (tenant) {
|
||||
tenantSlugByKey.set(key, tenant.slug);
|
||||
tenantByKey.set(key, {
|
||||
id: tenant.id,
|
||||
slug: tenant.slug,
|
||||
emailDomain: preview.row.emailDomain,
|
||||
});
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -231,27 +238,33 @@ export function UserBulkUploadModal({ onSuccess }: UserBulkUploadModalProps) {
|
||||
domains: splitTenantImportDomains(preview.row.emailDomain),
|
||||
status: "active",
|
||||
});
|
||||
tenantSlugByKey.set(key, created.slug);
|
||||
tenantByKey.set(key, {
|
||||
id: created.id,
|
||||
slug: created.slug,
|
||||
emailDomain: preview.row.emailDomain,
|
||||
});
|
||||
}
|
||||
|
||||
return previewData.map((user, index) => {
|
||||
const key = tenantImportKeyFromUser(user);
|
||||
const tenantSlug = key ? tenantSlugByKey.get(key) : user.tenantSlug;
|
||||
const resolvedTenant = key ? tenantByKey.get(key) : undefined;
|
||||
const emailPreview = hanmacEmailPreviews[index];
|
||||
const { tenantImport: _tenantImport, ...payload } = user;
|
||||
return {
|
||||
...payload,
|
||||
email: emailPreview?.finalEmail ?? payload.email,
|
||||
tenantSlug,
|
||||
tenantId: resolvedTenant?.id ?? payload.tenantId,
|
||||
tenantSlug: resolvedTenant?.slug ?? payload.tenantSlug,
|
||||
emailDomain: resolvedTenant?.emailDomain ?? payload.emailDomain,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
const downloadTemplate = () => {
|
||||
const headers =
|
||||
"email,name,phone,role,tenant_slug,department,grade,position,jobTitle,employee_id";
|
||||
"email,name,phone,role,tenant_slug,department,grade,position,jobTitle,employee_id,tenant_slug1,department1,grade1,position1,jobTitle1,employee_id1";
|
||||
const example =
|
||||
"user1@example.com,홍길동,010-1234-5678,user,tenant-slug,개발팀,수석,팀장,프론트엔드,EMP001";
|
||||
"user1@example.com,홍길동,010-1234-5678,user,tenant-slug,개발팀,수석,팀장,프론트엔드,EMP001,second-tenant,센터,책임,,Architecture,EMP002";
|
||||
const blob = new Blob([`${headers}\n${example}`], {
|
||||
type: "text/csv;charset=utf-8;",
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user