'use client' // apps/admin/src/components/admin-sidebar.tsx // D3RO Voice Admin CRM — "Midnight Glass v2" Floating Navigation Island import { usePathname, useRouter } from 'next/navigation' import { Box, Typography } from '@mui/material' import { C, FONT_SANS, FONT_MONO } from '@/lib/console-theme' import { getSupabaseBrowserClient } from '@/lib/supabase-browser' interface NavGroup { title: string items: Array<{ key: string path: string label: string icon: React.ReactElement }> } const NAV_GROUPS: NavGroup[] = [ { title: 'Core Platform', items: [ { key: 'overview', path: '/', label: 'Dashboard Overview', icon: ( ), }, { key: 'pipelines', path: '/pipelines', label: 'AI & Voice Pipelines', icon: ( ), }, { key: 'models', path: '/models', label: 'Service Models', icon: ( ), }, { key: 'releases', path: '/releases', label: 'Release & Downloads', icon: ( ), }, ], }, { title: 'Customer & Revenue', items: [ { key: 'users', path: '/users', label: 'User Directory', icon: ( ), }, { key: 'subscriptions', path: '/subscriptions', label: 'Subscriptions & ARR', icon: ( ), }, { key: 'ads', path: '/ads', label: 'Ad Monetization', icon: ( ), }, { key: 'support', path: '/support', label: 'Customer Support (CA)', icon: ( ), }, ], }, { title: 'Intelligence & Security', items: [ { key: 'usage', path: '/usage', label: 'Usage & Token Costs', icon: ( ), }, { key: 'audit-log', path: '/audit-log', label: 'Security Audit Log', icon: ( ), }, ], }, ] export function AdminSidebar({ identity }: { identity: { email: string; role: 'manager' | 'admin' | 'super_admin' } }): React.ReactElement { const pathname = usePathname() const router = useRouter() const handleLogout = async (): Promise => { try { await fetch('/api/auth/logout', { method: 'POST' }) } catch { // ignore } try { const supabase = getSupabaseBrowserClient() await supabase.auth.signOut().catch(() => {}) } catch { // ignore } router.replace('/login') router.refresh() } const isActive = (path: string): boolean => path === '/' ? pathname === '/' : pathname.startsWith(path) return ( {/* Top Ambient Sheen */} {/* Brand Header */} {/* Logo Mark */} D3RO Voice INTELLIGENCE CRM {/* Verified local session indicator */} SESSION {/* Nav Scroll Area */} {NAV_GROUPS.map((group) => ( {group.title} {group.items.map((item) => { const active = isActive(item.path) return ( router.push(item.path)} sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', px: 1.75, py: 1.1, borderRadius: '12px', cursor: 'pointer', position: 'relative', border: `1px solid ${active ? 'var(--d3-accent-glow)' : 'transparent'}`, bgcolor: active ? 'var(--d3-accent-glow)' : 'transparent', color: active ? C.bright : C.text, boxShadow: active ? '0 0 20px var(--d3-accent-glow), inset 0 1px 0 var(--d3-overlay-strong)' : 'none', transition: 'all 0.18s cubic-bezier(0.16, 1, 0.3, 1)', '&:hover': { bgcolor: active ? 'var(--d3-accent-glow)' : 'var(--d3-bg-raised-soft)', borderColor: active ? 'var(--d3-accent-light)' : C.border, color: C.bright, transform: 'translateX(3px)', }, '&:active': { transform: 'scale(0.98)', }, }} > {item.icon} {item.label} ) })} ))} {/* User Footer */} {identity.email.slice(0, 1).toUpperCase()} {identity.email} {identity.role.toUpperCase()} void handleLogout()} title="Sign Out" sx={{ p: 0.75, borderRadius: '8px', color: C.dim, cursor: 'pointer', display: 'flex', alignItems: 'center', justifyContent: 'center', transition: 'all 0.15s ease', '&:hover': { color: C.red400, bgcolor: 'var(--d3-status-danger)', }, }} > ) }