import { type ReactNode } from 'react'; import { Clock, Gauge, MessageSquare, Settings } from 'lucide-react'; import { type DashboardOverview, type StatusSnapshot } from './api'; import { type Messages } from './i18n'; export type DashboardView = 'usage' | 'rooms' | 'scheduled' | 'settings'; export type DashboardFreshness = 'fresh' | 'stale' | 'offline'; interface DashboardNavData { overview: DashboardOverview; snapshots: StatusSnapshot[]; } const NAV_ICONS: Record = { usage: , rooms: , scheduled: , settings: , }; function navItems(t: Messages) { return [ { href: '#/rooms', label: t.nav.rooms, view: 'rooms' as const }, { href: '#/scheduled', label: t.nav.scheduled, view: 'scheduled' as const }, { href: '#/usage', label: t.nav.usage, view: 'usage' as const }, { href: '#/settings', label: t.nav.settings, view: 'settings' as const }, ]; } function navStats(data: DashboardNavData | null) { if (!data) return null; const queue = data.snapshots.reduce( (acc, snapshot) => { for (const entry of snapshot.entries) { if (entry.status === 'processing') acc.processing += 1; } return acc; }, { processing: 0 }, ); return { processing: queue.processing, }; } function navBadge( view: DashboardView, stats: ReturnType, ): number | null { if (view === 'rooms' && stats && stats.processing > 0) { return stats.processing; } return null; } function DashboardBrandLink({ onNavigate, }: { onNavigate: (view: DashboardView) => void; }) { return ( onNavigate('rooms')} title="EJClaw" > EJ ); } function DashboardNavLinks({ activeView, data, onAfterNavigate, onNavigate, t, }: { activeView: DashboardView; data: DashboardNavData | null; onAfterNavigate?: () => void; onNavigate: (view: DashboardView) => void; t: Messages; }) { const stats = navStats(data); return ( ); } export function SideRail({ activeView, data, onNavigate, t, }: { activeView: DashboardView; data: DashboardNavData | null; onNavigate: (view: DashboardView) => void; t: Messages; }) { return ( ); } export function SectionNav({ activeView, data, drawerOpen, freshness, freshnessText, onCloseDrawer, onNavigate, onOpenDrawer, onRefresh, refreshing, t, }: { activeView: DashboardView; data: DashboardNavData | null; drawerOpen: boolean; freshness: DashboardFreshness; freshnessText: string; onCloseDrawer: () => void; onNavigate: (view: DashboardView) => void; onOpenDrawer: () => void; onRefresh: () => void; refreshing: boolean; t: Messages; }) { const activeLabel = navItems(t).find((item) => item.view === activeView)?.label ?? t.nav.rooms; const showManualRefresh = freshness !== 'fresh'; return ( <> {drawerOpen ? ( <> ) : null} ); }