diff --git a/adminfront/src/components/layout/AppLayout.tsx b/adminfront/src/components/layout/AppLayout.tsx index efb9f91b..ab256578 100644 --- a/adminfront/src/components/layout/AppLayout.tsx +++ b/adminfront/src/components/layout/AppLayout.tsx @@ -60,8 +60,8 @@ function AppLayout() { icon: Building2, }); } else if (isTenantAdmin) { - if (manageableCount === 1 && profile?.tenantId) { - // Direct link if only one tenant + if (manageableCount <= 1 && profile?.tenantId) { + // Direct link if only one (or zero in array but has tenantId) tenant items.splice(1, 0, { label: "ui.admin.nav.my_tenant", to: `/tenants/${profile.tenantId}`, diff --git a/adminfront/src/features/tenants/routes/TenantListPage.tsx b/adminfront/src/features/tenants/routes/TenantListPage.tsx index 5b9dfb5a..669181c1 100644 --- a/adminfront/src/features/tenants/routes/TenantListPage.tsx +++ b/adminfront/src/features/tenants/routes/TenantListPage.tsx @@ -36,11 +36,12 @@ function TenantListPage() { queryFn: fetchMe, }); - // Redirect tenant_admin ONLY if they have exactly one manageable tenant + // Redirect tenant_admin ONLY if they have one or fewer manageable tenants in the list React.useEffect(() => { if (profile?.role === "tenant_admin") { const manageableCount = profile.manageableTenants?.length ?? 0; - if (manageableCount === 1 && profile.tenantId) { + // If only 1 in array, OR array is empty but we have a primary tenantId + if ((manageableCount === 1 || manageableCount === 0) && profile.tenantId) { navigate(`/tenants/${profile.tenantId}`, { replace: true }); } }