import React from 'react';
import { useNavigate, useLocation } from 'react-router-dom';
import {
Drawer,
List,
ListItem,
ListItemButton,
ListItemIcon,
ListItemText,
Box,
Typography,
Avatar
} from '@mui/material';
import {
LiveTv,
Movie,
Theaters,
Favorite,
Settings,
Radio as RadioIcon,
BarChart,
Security
} from '@mui/icons-material';
import { useTranslation } from 'react-i18next';
import { useAuthStore } from '../store/authStore';
import Logo from './Logo';
const drawerWidth = 200;
function Sidebar({ open, onClose }) {
const { t } = useTranslation();
const navigate = useNavigate();
const location = useLocation();
const { user } = useAuthStore();
const menuItems = [
{ text: 'live_tv', icon: , path: '/live-tv' },
{ text: 'radio', icon: , path: '/radio' },
{ text: 'favorite_tv', icon: , path: '/favorites/tv' },
{ text: 'favorite_radio', icon: , path: '/favorites/radio' },
...(user?.role === 'admin' ? [
{ text: 'Analytics', icon: , path: '/stats' },
{ text: 'security.title', icon: , path: '/security' }
] : []),
{ text: 'settings.title', icon: , path: '/settings' }
];
const handleNavigate = (path) => {
navigate(path);
onClose();
};
const drawerContent = (
<>
{t('app_name')}
{user?.username?.[0]?.toUpperCase()}
{user?.username}
{menuItems.map((item) => {
const isActive = location.pathname === item.path ||
(item.path === '/live-tv' && location.pathname === '/') ||
(item.path === '/favorites/tv' && location.pathname === '/favorites');
return (
handleNavigate(item.path)}
sx={{
borderRadius: 1.5,
minHeight: 36,
py: 0.75,
'&.Mui-selected': {
bgcolor: 'primary.main',
color: 'white',
'&:hover': {
bgcolor: 'primary.dark'
},
'& .MuiListItemIcon-root': {
color: 'white'
}
}
}}
>
{item.icon}
);
})}
>
);
return (
<>
{/* Mobile drawer - temporary */}
{drawerContent}
{/* Desktop drawer - permanent, always visible */}
{drawerContent}
>
);
}
export default Sidebar;