1
0
forked from baron/baron-sso

feat: handle multiple manageable tenants for tenant admin

This commit is contained in:
2026-03-04 13:45:54 +09:00
parent d9ed46f4b9
commit 88720b48c4
2 changed files with 25 additions and 14 deletions

View File

@@ -36,17 +36,20 @@ function TenantListPage() {
queryFn: fetchMe,
});
// Redirect tenant_admin to their own tenant
// Redirect tenant_admin ONLY if they have exactly one manageable tenant
React.useEffect(() => {
if (profile?.role === "tenant_admin" && profile?.tenantId) {
navigate(`/tenants/${profile.tenantId}`, { replace: true });
if (profile?.role === "tenant_admin") {
const manageableCount = profile.manageableTenants?.length ?? 0;
if (manageableCount === 1 && profile.tenantId) {
navigate(`/tenants/${profile.tenantId}`, { replace: true });
}
}
}, [profile, navigate]);
const query = useQuery({
queryKey: ["tenants", { limit: 1000, offset: 0 }],
queryFn: () => fetchTenants(1000, 0),
enabled: profile?.role === "super_admin",
enabled: profile?.role === "super_admin" || (profile?.role === "tenant_admin" && (profile.manageableTenants?.length ?? 0) > 1),
});
const deleteMutation = useMutation({