import { useMemo } from 'react'; import { Puzzle, KeyRound, UserCircle } from 'lucide-react'; import type { LayoutNode, PanelComponents } from 'officerdev'; import { WorkspaceLayout } from 'officerdev'; import { useAuth } from 'hooks/useAuth'; import { useGlobal } from 'hooks/useGlobal'; import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs'; import { SettingsSidebar, SettingsContent, type SettingsSection } from '../SettingsPanel'; import { GoogleOAuthConfig } from './GoogleOAuthConfig'; import { GoogleAccount } from './GoogleAccount'; const GLOBAL_KEY = 'INTEGRATIONS_SETTINGS_SELECTED'; const TAB_KEY = 'INTEGRATIONS_SETTINGS_TAB'; const enterpriseSections: SettingsSection[] = [ { key: 'google-oauth', icon: KeyRound, title: 'Google OAuth', description: 'Client ID and secret for Google APIs', content: }, ]; const personalSections: SettingsSection[] = [ { key: 'google-account', icon: UserCircle, title: 'Google Account', description: 'Connect your Google account', content: }, ]; const IntegrationsSidebar = () => { const { user } = useAuth(); const isSuperAdmin = user?.role === 'Super Admin'; const [tab, setTab] = useGlobal(TAB_KEY, isSuperAdmin ? 'enterprise' : 'personal'); const sections = tab === 'enterprise' ? enterpriseSections : personalSections; return (
Integrations
{isSuperAdmin && (
Enterprise Personal
)}
); }; const IntegrationsContent = () => { const { user } = useAuth(); const isSuperAdmin = user?.role === 'Super Admin'; const [tab] = useGlobal(TAB_KEY, isSuperAdmin ? 'enterprise' : 'personal'); const sections = tab === 'enterprise' ? enterpriseSections : personalSections; return ; }; const layout: LayoutNode = { type: 'group', id: 'integrations-root', direction: 'horizontal', children: [ { node: { type: 'panel', id: 'integrations-left', appType: null }, size: 20 }, { node: { type: 'panel', id: 'integrations-right', appType: null }, size: 80 }, ], }; export const IntegrationsSettings = () => { const panelComponents: PanelComponents = useMemo( () => ({ 'integrations-left': IntegrationsSidebar, 'integrations-right': IntegrationsContent, }), [], ); return (
{}} components={panelComponents} />
); };