'use client' // apps/web/src/components/layout/sidebar.tsx // D3RO VOICE 대시보드 좌측 사이드바 — 정본 네비게이션 import { usePathname, useRouter } from 'next/navigation' import { Box, FormControl, InputLabel, List, ListItem, ListItemButton, ListItemIcon, ListItemText, MenuItem, Select, type SelectChangeEvent } from '@mui/material' import DashboardIcon from '@mui/icons-material/Dashboard' import MicIcon from '@mui/icons-material/Mic' import HistoryIcon from '@mui/icons-material/History' import ChatIcon from '@mui/icons-material/Chat' import BookIcon from '@mui/icons-material/Book' import AutoAwesomeIcon from '@mui/icons-material/AutoAwesome' import PaymentIcon from '@mui/icons-material/Payment' import LogoutIcon from '@mui/icons-material/Logout' import PaletteIcon from '@mui/icons-material/Palette' import type { ThemeMode } from '@d3ro/core/types' import { PhosphorText } from '@d3ro/ui/components/ds' import { d3roPalette } from '@d3ro/ui/theme' import { useI18n } from '@d3ro/i18n' import { getSupabaseBrowserClient } from '@/lib/supabase-browser' import { AVAILABLE_MODES, useThemeMode } from '@/components/providers/theme-mode-context' interface NavItem { key: string path: string label: string icon: React.ReactElement } export function Sidebar(): React.ReactElement { const router = useRouter() const pathname = usePathname() const { t } = useI18n() const { mode, setMode } = useThemeMode() const handleThemeChange = (event: SelectChangeEvent): void => { setMode(event.target.value as ThemeMode) } const items: NavItem[] = [ { key: 'dashboard', path: '/dashboard', label: t('nav.dashboard') ?? '대시보드', icon: }, { key: 'record', path: '/record', label: t('nav.record') ?? '실시간 녹음', icon: }, { key: 'history', path: '/history', label: t('nav.history') ?? '전사 히스토리', icon: }, { key: 'chat', path: '/chat', label: t('nav.chat') ?? '음성 대화', icon: }, { key: 'dictionary', path: '/dictionary', label: t('nav.dictionary') ?? '커스텀 사전', icon: }, { key: 'commands', path: '/commands', label: t('nav.commands') ?? '명령어', icon: }, { key: 'billing', path: '/billing', label: t('nav.billing') ?? '구독 & 업그레이드', icon: } ] async function handleLogout(): Promise { const supabase = getSupabaseBrowserClient() await supabase.auth.signOut() router.replace('/login') } return ( D3RO VOICE v1.2.0 {items.map((item) => { const active = pathname === item.path || pathname.startsWith(`${item.path}/`) return ( router.push(item.path)} sx={{ py: 1.25, '&.Mui-selected': { bgcolor: d3roPalette.bg.inset, borderLeft: `3px solid ${d3roPalette.accent.main}` } }} > {item.icon} ) })} {t('theme.label') ?? 'Theme'} labelId="theme-mode-label" id="theme-mode-select" value={mode} onChange={handleThemeChange} label={t('theme.label') ?? 'Theme'} > {AVAILABLE_MODES.map((m) => ( {t(`theme.${m}`) ?? m} ))} void handleLogout()}> ) }