import { Home, Layers, Radar, Clock, Settings as SettingsIcon } from 'lucide-react'; import type { LucideIcon } from 'lucide-react'; import { cn } from '@/lib/utils'; import type { NavItem, ActiveView } from './EditorLayout/hooks/useViewNavigationState'; import type { MobileView } from './EditorLayout/mobile-surface'; type TabId = 'home' | 'stacks' | 'fleet' | 'schedules' | 'settings'; interface MobileTabBarProps { /** The already-gated nav items (admin / remote / paid filtering applied). */ navItems: NavItem[]; activeView: ActiveView; /** Which top-level mobile surface is showing when no stack detail is open. */ mobileView: MobileView; /** True while a stack detail is open (keeps the Stacks tab marked current). */ detailOpen: boolean; onHome: () => void; onStacks: () => void; onNavigate: (view: ActiveView) => void; onSettings: () => void; } interface Tab { id: TabId; label: string; icon: LucideIcon; view?: ActiveView; } /** * Bottom tab bar for the mobile shell (hidden at md+). Five primary * destinations: Home (dashboard), Stacks (the list), Fleet, Sched, Settings. * Fleet and Sched only appear when present in the gated `navItems`, so the bar * never exposes a flow the desktop nav would hide (admin-only schedules, * hub-only views on a remote node). Everything else stays reachable through the * masthead "more" menu on bespoke screens, or the TopBar nav sheet elsewhere. */ export function MobileTabBar({ navItems, activeView, mobileView, detailOpen, onHome, onStacks, onNavigate, onSettings, }: MobileTabBarProps) { const has = (value: ActiveView) => navItems.some(i => i.value === value); const tabs: Tab[] = [ { id: 'home', label: 'Home', icon: Home }, { id: 'stacks', label: 'Stacks', icon: Layers }, ...(has('fleet') ? [{ id: 'fleet' as const, label: 'Fleet', icon: Radar, view: 'fleet' as const }] : []), ...(has('scheduled-ops') ? [{ id: 'schedules' as const, label: 'Sched', icon: Clock, view: 'scheduled-ops' as const }] : []), { id: 'settings', label: 'Settings', icon: SettingsIcon }, ]; const currentTab = (): TabId | null => { if (detailOpen || mobileView === 'list') return 'stacks'; if (activeView === 'dashboard') return 'home'; if (activeView === 'fleet') return 'fleet'; if (activeView === 'scheduled-ops') return 'schedules'; if (activeView === 'settings') return 'settings'; return null; }; const current = currentTab(); const select = (tab: Tab) => { if (tab.id === 'home') onHome(); else if (tab.id === 'stacks') onStacks(); else if (tab.id === 'settings') onSettings(); else if (tab.view) onNavigate(tab.view); }; return ( ); }