import * as React from "react"; import { useCurrentUser } from "../lib/api/current-user"; import { getLocaleDir } from "../locales/config.js"; import { useLocale } from "../locales/useLocale.js"; import { AdminCommandPalette } from "./AdminCommandPalette"; import { Header } from "./Header"; import { Sidebar, SidebarNav } from "./Sidebar"; import { WelcomeModal } from "./WelcomeModal"; export interface ShellProps { children: React.ReactNode; manifest: { collections: Record; plugins: Record< string, { package?: string; adminPages?: Array<{ path: string; label?: string; icon?: string }>; } >; taxonomies: Array<{ name: string; label: string; }>; version?: string; }; } /** * Admin shell layout with kumo Sidebar component. * * Sidebar.Provider wraps both the sidebar and main content area, * handling collapse state, mobile detection, and layout transitions. */ export function Shell({ children, manifest }: ShellProps) { const [welcomeModalOpen, setWelcomeModalOpen] = React.useState(false); const { data: user } = useCurrentUser(); const { locale } = useLocale(); const sidebarSide = getLocaleDir(locale) === "rtl" ? "right" : "left"; // Show welcome modal on first login React.useEffect(() => { if (user?.isFirstLogin) { setWelcomeModalOpen(true); } }, [user?.isFirstLogin]); return ( {/* Sidebar navigation */} {/* Main content area — scrolls independently so sidebar stays full height */}
{children}
{/* Welcome modal for first-time users */} {user && ( setWelcomeModalOpen(false)} userName={user.name} userRole={user.role} /> )} {/* Command palette for quick navigation */}
); }