import { ReactNode, useState } from 'react'
import {
Box,
Drawer,
AppBar,
Toolbar,
List,
Typography,
Divider,
IconButton,
ListItem,
ListItemButton,
ListItemIcon,
ListItemText,
Button,
} from '@mui/material'
import {
Menu as MenuIcon,
Dashboard as DashboardIcon,
Label as KeywordIcon,
AccountTree as PipelineIcon,
People as PeopleIcon,
Apps as AppsIcon,
Article as ArticleIcon,
BarChart as MonitoringIcon,
} from '@mui/icons-material'
import { useNavigate, useLocation } from 'react-router-dom'
import { useAuthStore } from '../stores/authStore'
const drawerWidth = 240
interface MainLayoutProps {
children: ReactNode
}
interface MenuItem {
text: string
icon: ReactNode
path: string
}
const menuItems: MenuItem[] = [
{ text: 'Dashboard', icon: , path: '/dashboard' },
{ text: 'Keywords', icon: , path: '/keywords' },
{ text: 'Pipelines', icon: , path: '/pipelines' },
{ text: 'Users', icon: , path: '/users' },
{ text: 'Applications', icon: , path: '/applications' },
{ text: 'Articles', icon: , path: '/articles' },
{ text: 'Monitoring', icon: , path: '/monitoring' },
]
export default function MainLayout({ children }: MainLayoutProps) {
const [mobileOpen, setMobileOpen] = useState(false)
const navigate = useNavigate()
const location = useLocation()
const { user, logout } = useAuthStore()
const handleDrawerToggle = () => {
setMobileOpen(!mobileOpen)
}
const handleLogout = async () => {
await logout()
navigate('/login')
}
const handleNavigate = (path: string) => {
navigate(path)
setMobileOpen(false)
}
const drawer = (
News Engine
{menuItems.map((item) => (
handleNavigate(item.path)}
>
{item.icon}
))}
)
return (
News Engine Console
{user?.full_name} ({user?.role})
{/* Mobile drawer */}
{drawer}
{/* Desktop drawer */}
{drawer}
{children}
)
}