import { useState } from 'react' import { Button } from '@/components/ui/button' import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetTrigger } from '@/components/ui/sheet' import { ScrollArea } from '@/components/ui/scroll-area' import { Badge } from '@/components/ui/badge' import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible' import { List, ChartBar, Code, Database, Tree, FlowArrow, PaintBrush, Flask, Play, BookOpen, Cube, Wrench, FileText, Gear, DeviceMobile, Image, Faders, CaretDown, CaretDoubleDown, CaretDoubleUp, Cloud, } from '@phosphor-icons/react' import { FeatureToggles } from '@/types/project' interface NavigationGroup { id: string label: string items: NavigationItem[] } interface NavigationItem { id: string label: string icon: React.ReactNode value: string badge?: number featureKey?: keyof FeatureToggles } interface NavigationMenuProps { activeTab: string onTabChange: (tab: string) => void featureToggles: FeatureToggles errorCount?: number } export function NavigationMenu({ activeTab, onTabChange, featureToggles, errorCount = 0, }: NavigationMenuProps) { const [open, setOpen] = useState(false) const [expandedGroups, setExpandedGroups] = useState>( new Set(['overview', 'development', 'automation', 'design', 'backend', 'testing', 'tools']) ) const navigationGroups: NavigationGroup[] = [ { id: 'overview', label: 'Overview', items: [ { id: 'dashboard', label: 'Dashboard', icon: , value: 'dashboard', }, ], }, { id: 'development', label: 'Development', items: [ { id: 'code', label: 'Code Editor', icon: , value: 'code', featureKey: 'codeEditor', }, { id: 'models', label: 'Models', icon: , value: 'models', featureKey: 'models', }, { id: 'components', label: 'Components', icon: , value: 'components', featureKey: 'components', }, { id: 'component-trees', label: 'Component Trees', icon: , value: 'component-trees', featureKey: 'componentTrees', }, ], }, { id: 'automation', label: 'Automation', items: [ { id: 'workflows', label: 'Workflows', icon: , value: 'workflows', featureKey: 'workflows', }, { id: 'lambdas', label: 'Lambdas', icon: , value: 'lambdas', featureKey: 'lambdas', }, ], }, { id: 'design', label: 'Design & Styling', items: [ { id: 'styling', label: 'Styling', icon: , value: 'styling', featureKey: 'styling', }, { id: 'sass', label: 'Sass Styles', icon: , value: 'sass', featureKey: 'sassStyles', }, { id: 'favicon', label: 'Favicon Designer', icon: , value: 'favicon', featureKey: 'faviconDesigner', }, ], }, { id: 'backend', label: 'Backend', items: [ { id: 'flask', label: 'Flask API', icon: , value: 'flask', featureKey: 'flaskApi', }, ], }, { id: 'testing', label: 'Testing', items: [ { id: 'playwright', label: 'Playwright', icon: , value: 'playwright', featureKey: 'playwright', }, { id: 'storybook', label: 'Storybook', icon: , value: 'storybook', featureKey: 'storybook', }, { id: 'unit-tests', label: 'Unit Tests', icon: , value: 'unit-tests', featureKey: 'unitTests', }, ], }, { id: 'tools', label: 'Tools & Configuration', items: [ { id: 'errors', label: 'Error Repair', icon: , value: 'errors', badge: errorCount, featureKey: 'errorRepair', }, { id: 'docs', label: 'Documentation', icon: , value: 'docs', featureKey: 'documentation', }, { id: 'settings', label: 'Settings', icon: , value: 'settings', }, { id: 'pwa', label: 'PWA', icon: , value: 'pwa', }, { id: 'features', label: 'Features', icon: , value: 'features', }, ], }, ] const handleItemClick = (value: string) => { onTabChange(value) setOpen(false) } const toggleGroup = (groupId: string) => { setExpandedGroups((prev) => { const newSet = new Set(prev) if (newSet.has(groupId)) { newSet.delete(groupId) } else { newSet.add(groupId) } return newSet }) } const isItemVisible = (item: NavigationItem) => { if (!item.featureKey) return true return featureToggles[item.featureKey] } const getVisibleItemsCount = (group: NavigationGroup) => { return group.items.filter(isItemVisible).length } const handleExpandAll = () => { const allGroupIds = navigationGroups .filter((group) => getVisibleItemsCount(group) > 0) .map((group) => group.id) setExpandedGroups(new Set(allGroupIds)) } const handleCollapseAll = () => { setExpandedGroups(new Set()) } return ( Navigation
{navigationGroups.map((group) => { const visibleItemsCount = getVisibleItemsCount(group) if (visibleItemsCount === 0) return null const isExpanded = expandedGroups.has(group.id) return ( toggleGroup(group.id)} >

{group.label}

{visibleItemsCount}
{group.items.map((item) => { if (!isItemVisible(item)) return null const isActive = activeTab === item.value return ( ) })}
) })}
) }