forked from baron/baron-sso
fix(adminfront): fix tenant slug display and metadata save issue in user detail page
- Fix 'System Global' displaying by replacing user.tenantSlug with user.companyCode returned by backend - Prevent primary tenant from being unlinked when saving 'Tenant Profile' tab by ensuring userAffiliatedTenants always includes the primary tenant, preventing react-hook-form from clearing the tenantSlug value.
This commit is contained in:
@@ -391,7 +391,7 @@ function UserDetailPage() {
|
|||||||
phone: user.phone || "",
|
phone: user.phone || "",
|
||||||
role: user.role,
|
role: user.role,
|
||||||
status: user.status,
|
status: user.status,
|
||||||
tenantSlug: user.tenantSlug || "",
|
tenantSlug: user.companyCode || "",
|
||||||
department: user.department || "",
|
department: user.department || "",
|
||||||
position: user.position || "",
|
position: user.position || "",
|
||||||
jobTitle: user.jobTitle || "",
|
jobTitle: user.jobTitle || "",
|
||||||
@@ -484,8 +484,15 @@ function UserDetailPage() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const userAffiliatedTenants =
|
const userAffiliatedTenants = React.useMemo(() => {
|
||||||
user.joinedTenants || (user.tenant ? [user.tenant] : []);
|
const joined = user.joinedTenants || [];
|
||||||
|
const primary = user.tenant;
|
||||||
|
const all = [...joined];
|
||||||
|
if (primary && !joined.some((t) => t.id === primary.id)) {
|
||||||
|
all.unshift(primary);
|
||||||
|
}
|
||||||
|
return all;
|
||||||
|
}, [user.joinedTenants, user.tenant]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
@@ -525,7 +532,7 @@ function UserDetailPage() {
|
|||||||
>
|
>
|
||||||
<Building2 size={12} className="mr-1.5" />
|
<Building2 size={12} className="mr-1.5" />
|
||||||
{user.tenant?.name ||
|
{user.tenant?.name ||
|
||||||
user.tenantSlug ||
|
user.companyCode ||
|
||||||
t("ui.admin.users.detail.form.tenant_global", "시스템 전역")}
|
t("ui.admin.users.detail.form.tenant_global", "시스템 전역")}
|
||||||
</Badge>
|
</Badge>
|
||||||
<Badge
|
<Badge
|
||||||
|
|||||||
Reference in New Issue
Block a user