import { Outlet, NavLink, useNavigate } from 'react-router-dom' import { useTranslation } from 'react-i18next' import { useAuthStore } from '@/store/authStore' import { apiClientV2 } from '@/services/apiV2' import LanguageSwitcher from '@/components/LanguageSwitcher' import { Upload, FileText, Activity, LogOut, LayoutDashboard, ChevronRight, History, Shield } from 'lucide-react' export default function Layout() { const { t } = useTranslation() const navigate = useNavigate() const logout = useAuthStore((state) => state.logout) const user = useAuthStore((state) => state.user) // Check if user is admin const isAdmin = user?.email === 'ymirliu@panjit.com.tw' const handleLogout = async () => { try { await apiClientV2.logout() } catch (error) { console.error('Logout error:', error) } finally { logout() navigate('/login') } } const navLinks = [ { to: '/upload', label: t('nav.upload'), icon: Upload, description: '上傳檔案', adminOnly: false }, { to: '/processing', label: t('nav.processing'), icon: Activity, description: '處理進度', adminOnly: false }, { to: '/results', label: t('nav.results'), icon: FileText, description: '查看結果', adminOnly: false }, { to: '/tasks', label: '任務歷史', icon: History, description: '查看任務記錄', adminOnly: false }, { to: '/admin', label: '管理員儀表板', icon: Shield, description: '系統管理', adminOnly: true }, ] // Filter nav links based on admin status const visibleNavLinks = navLinks.filter(link => !link.adminOnly || isAdmin) return (