33import dynamic from 'next/dynamic'
44import { useSearchParams } from 'next/navigation'
55import { Skeleton } from '@/components/emcn'
6+ import { useSession } from '@/lib/auth/auth-client'
7+ import { AdminSkeleton } from '@/app/workspace/[workspaceId]/settings/components/admin/admin-skeleton'
68import { ApiKeysSkeleton } from '@/app/workspace/[workspaceId]/settings/components/api-keys/api-key-skeleton'
79import { BYOKSkeleton } from '@/app/workspace/[workspaceId]/settings/components/byok/byok-skeleton'
810import { CopilotSkeleton } from '@/app/workspace/[workspaceId]/settings/components/copilot/copilot-skeleton'
911import { CredentialSetsSkeleton } from '@/app/workspace/[workspaceId]/settings/components/credential-sets/credential-sets-skeleton'
1012import { CredentialsSkeleton } from '@/app/workspace/[workspaceId]/settings/components/credentials/credential-skeleton'
1113import { CustomToolsSkeleton } from '@/app/workspace/[workspaceId]/settings/components/custom-tools/custom-tool-skeleton'
12- import { DebugSkeleton } from '@/app/workspace/[workspaceId]/settings/components/debug/debug-skeleton'
1314import { GeneralSkeleton } from '@/app/workspace/[workspaceId]/settings/components/general/general-skeleton'
1415import { InboxSkeleton } from '@/app/workspace/[workspaceId]/settings/components/inbox/inbox-skeleton'
1516import { McpSkeleton } from '@/app/workspace/[workspaceId]/settings/components/mcp/mcp-skeleton'
@@ -130,10 +131,10 @@ const Inbox = dynamic(
130131 import ( '@/app/workspace/[workspaceId]/settings/components/inbox/inbox' ) . then ( ( m ) => m . Inbox ) ,
131132 { loading : ( ) => < InboxSkeleton /> }
132133)
133- const Debug = dynamic (
134+ const Admin = dynamic (
134135 ( ) =>
135- import ( '@/app/workspace/[workspaceId]/settings/components/debug/debug ' ) . then ( ( m ) => m . Debug ) ,
136- { loading : ( ) => < DebugSkeleton /> }
136+ import ( '@/app/workspace/[workspaceId]/settings/components/admin/admin ' ) . then ( ( m ) => m . Admin ) ,
137+ { loading : ( ) => < AdminSkeleton /> }
137138)
138139const RecentlyDeleted = dynamic (
139140 ( ) =>
@@ -157,9 +158,15 @@ interface SettingsPageProps {
157158export function SettingsPage ( { section } : SettingsPageProps ) {
158159 const searchParams = useSearchParams ( )
159160 const mcpServerId = searchParams . get ( 'mcpServerId' )
161+ const { data : session , isPending : sessionLoading } = useSession ( )
160162
163+ const isAdminRole = session ?. user ?. role === 'admin'
161164 const effectiveSection =
162- ! isBillingEnabled && ( section === 'subscription' || section === 'team' ) ? 'general' : section
165+ ! isBillingEnabled && ( section === 'subscription' || section === 'team' )
166+ ? 'general'
167+ : section === 'admin' && ! sessionLoading && ! isAdminRole
168+ ? 'general'
169+ : section
163170
164171 const label =
165172 allNavigationItems . find ( ( item ) => item . id === effectiveSection ) ?. label ?? effectiveSection
@@ -185,7 +192,7 @@ export function SettingsPage({ section }: SettingsPageProps) {
185192 { effectiveSection === 'workflow-mcp-servers' && < WorkflowMcpServers /> }
186193 { effectiveSection === 'inbox' && < Inbox /> }
187194 { effectiveSection === 'recently-deleted' && < RecentlyDeleted /> }
188- { effectiveSection === 'debug ' && < Debug /> }
195+ { effectiveSection === 'admin ' && < Admin /> }
189196 </ div >
190197 )
191198}
0 commit comments