import { ReactNode, useState, useRef, useEffect } from 'react'; import { useAuthStore } from '../../store/authStore'; import { useNavigate, useLocation } from 'react-router-dom'; import { LayoutDashboard, FolderOpen, LogOut, User, Settings, Menu, X, ChevronRight, Save, Cloud, Code2, Blocks, FileType } from 'lucide-react'; interface AppLayoutProps { children: ReactNode; sidebarContent?: ReactNode; showSidebar?: boolean; } export default function AppLayout({ children, sidebarContent, showSidebar }: AppLayoutProps) { const { user, logout } = useAuthStore(); const navigate = useNavigate(); const location = useLocation(); const isEditor = location.pathname.startsWith('/project/'); const [showProfileMenu, setShowProfileMenu] = useState(false); const profileRef = useRef(null); useEffect(() => { const handleClickOutside = (e: MouseEvent) => { if (profileRef.current && !profileRef.current.contains(e.target as Node)) { setShowProfileMenu(false); } }; document.addEventListener('mousedown', handleClickOutside); return () => document.removeEventListener('mousedown', handleClickOutside); }, []); return (
{/* Top Navigation */}
{isEditor && ( <> {useAuthStore.getState().token ? 'Project Editor' : ''} )}
{user && ( <> {user.username}
{showProfileMenu && (
)}
)}
{/* Main Content Area */}
{/* Sidebar (for editor) */} {showSidebar && sidebarContent && ( )} {/* Main Content */}
{children}
); }