import { A, useLocation, useNavigate } from '@solidjs/router'; import { createSignal, onMount, type JSX } from 'solid-js'; import AdminSidebar from './AdminSidebar'; import { clearAdminSession, hasAdminSession } from '~/lib/admin-session'; export default function AdminShell(props: { children: JSX.Element }) { const location = useLocation(); const navigate = useNavigate(); const [checkedSession, setCheckedSession] = createSignal(false); const tabs = [ { href: '/admin/runtime-roles', label: 'View Roles' }, { href: '/admin/runtime-roles/new', label: 'Create Role' }, { href: '/admin/role-ui-configs', label: 'Inspector' }, { href: '/admin/onboarding-schemas', label: 'Onboarding' }, ]; const isTabActive = (href: string) => { if (href === '/admin/runtime-roles') { return location.pathname === href || (location.pathname.startsWith('/admin/runtime-roles/') && location.pathname !== '/admin/runtime-roles/new'); } return location.pathname === href || location.pathname.startsWith(`${href}/`); }; onMount(() => { if (!hasAdminSession()) { const from = encodeURIComponent(location.pathname + location.search); navigate(`/login?from=${from}`, { replace: true }); return; } setCheckedSession(true); }); const onLogout = () => { clearAdminSession(); navigate('/login', { replace: true }); }; return (
Administration
Super Admin
Checking session...