/home/techb158/cosmic-risk.abdallabala.com/src/components
NameSizeModeActions
AppShell.jsx33760644editdlrm
ErrorBoundary.jsx9510644editdlrm
LogoutButton.jsx3950644editdlrm
Edit: /home/techb158/cosmic-risk.abdallabala.com/src/components/AppShell.jsx (3376B)
'use client'; import { useEffect, useState } from 'react'; import { useRouter, useSearchParams } from 'next/navigation'; import { getSession, logout } from '../lib/api-client'; const NAV_ITEMS = [ { label: 'Overview', tab: 'Overview', icon: '◇' }, { label: 'Projects', tab: 'Projects', icon: '▤' }, { label: 'Risks', tab: 'Risks', icon: '⚠' }, { label: 'Mitigations', tab: 'Mitigations', icon: '●' }, { label: 'Gate', tab: 'Gate', icon: '⊞' }, { label: 'Indicators', tab: 'Indicators', icon: '▦' }, { label: 'Experiments', tab: 'Experiments', icon: '⚗' }, { label: 'Reports', tab: 'Reports', icon: '◇' }, { label: 'Integrations', tab: 'Integrations', icon: '⇆' }, { label: 'Audit', tab: 'Audit', icon: '📋' }, { label: 'Members', tab: 'Members', icon: '👥' }, ]; export default function AppShell({ children }) { const [user, setUser] = useState(null); const [sidebarOpen, setSidebarOpen] = useState(false); const [loading, setLoading] = useState(true); const [platformRole, setPlatformRole] = useState('NONE'); const router = useRouter(); const searchParams = useSearchParams(); const currentTab = searchParams.get('tab') || 'Overview'; useEffect(() => { getSession().then(u => { if (!u) { router.replace('/login'); return; } setUser(u); setPlatformRole(u.platformRole || 'NONE'); setLoading(false); }); }, [router]); const isSuper = platformRole === 'SUPER_ADMIN' || platformRole === 'SUPER_OWNER'; const isSuperOwner = platformRole === 'SUPER_OWNER'; if (loading) { return (
); } const navItems = isSuper ? [{ label: 'Admin', tab: 'Admin', icon: '⚙' }] : NAV_ITEMS; return (
{sidebarOpen &&
setSidebarOpen(false)} />}
{children}
); }