From 12b8958a72fe3ccc11040cf60e14823bb47acf4b Mon Sep 17 00:00:00 2001 From: chan Date: Fri, 10 Apr 2026 17:44:00 +0900 Subject: [PATCH] fix(adminfront): fix react hooks violation in UserDetailPage causing infinite loading - Fix 'Rendered fewer hooks than expected' crash by moving useMemo hook definition above all early returns - Resolves e2e test timeout failures in users_schema.spec.ts and users.spec.ts --- .../src/features/users/UserDetailPage.tsx | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/adminfront/src/features/users/UserDetailPage.tsx b/adminfront/src/features/users/UserDetailPage.tsx index 00e8e87b..9b91229d 100644 --- a/adminfront/src/features/users/UserDetailPage.tsx +++ b/adminfront/src/features/users/UserDetailPage.tsx @@ -391,7 +391,12 @@ function UserDetailPage() { phone: user.phone || "", role: user.role, status: user.status, - tenantSlug: user.companyCode || "", + tenantSlug: + user.companyCode || + user.joinedTenants?.find( + (t) => t.type === "COMPANY" || t.type === "COMPANY_GROUP", + )?.slug || + "", department: user.department || "", position: user.position || "", jobTitle: user.jobTitle || "", @@ -459,6 +464,16 @@ function UserDetailPage() { } }; + const userAffiliatedTenants = React.useMemo(() => { + 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]); + if (isLoading) { return (
@@ -484,16 +499,6 @@ function UserDetailPage() { ); } - const userAffiliatedTenants = React.useMemo(() => { - 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 (
{/* Header with back button and actions */} @@ -533,6 +538,9 @@ function UserDetailPage() { {user.tenant?.name || user.companyCode || + user.joinedTenants?.find( + (t) => t.type === "COMPANY" || t.type === "COMPANY_GROUP", + )?.name || t("ui.admin.users.detail.form.tenant_global", "시스템 전역")}