نسخ من RaghadAlkhous/RestaurantDash
Linking of login, logout and registration interfaces.
هذا الالتزام موجود في:
@@ -22,25 +22,25 @@ const AnalyticsPage = () => {
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [sidebarOpen, setSidebarOpen] = useState(!isMobile);
|
||||
|
||||
const dailyData = [
|
||||
{ date: '10:00', visitors: 1500, conversions: 300 },
|
||||
{ date: '11:00', visitors: 1800, conversions: 320 },
|
||||
];
|
||||
const dailyData = [
|
||||
{ date: '10:00', visitors: 1500, conversions: 300 },
|
||||
{ date: '11:00', visitors: 1800, conversions: 320 },
|
||||
];
|
||||
|
||||
const weeklyData = [
|
||||
{ label: 'Week 1', visitors: 1500, conversions: 200 },
|
||||
{ label: 'Week 2', visitors: 2300, conversions: 400 },
|
||||
];
|
||||
const weeklyData = [
|
||||
{ label: 'Week 1', visitors: 1500, conversions: 200 },
|
||||
{ label: 'Week 2', visitors: 2300, conversions: 400 },
|
||||
];
|
||||
|
||||
const monthlyData = [
|
||||
{ label: 'Jan', visitors: 15000, conversions: 3000 },
|
||||
{ label: 'Feb', visitors: 18000, conversions: 4000 },
|
||||
];
|
||||
const monthlyData = [
|
||||
{ label: 'Jan', visitors: 15000, conversions: 3000 },
|
||||
{ label: 'Feb', visitors: 18000, conversions: 4000 },
|
||||
];
|
||||
|
||||
const yearlyData = [
|
||||
{ label: '2024', visitors: 25000, conversions: 7000 },
|
||||
{ label: '2025', visitors: 38000, conversions: 12000 },
|
||||
];
|
||||
const yearlyData = [
|
||||
{ label: '2024', visitors: 25000, conversions: 7000 },
|
||||
{ label: '2025', visitors: 38000, conversions: 12000 },
|
||||
];
|
||||
|
||||
|
||||
const getData = () => {
|
||||
@@ -94,11 +94,11 @@ const yearlyData = [
|
||||
}, [theme.breakpoints.values.md]);
|
||||
|
||||
return (
|
||||
<Box
|
||||
p={{ xs: 1, sm: 2 }}
|
||||
maxWidth="100%"
|
||||
overflowX="hidden"
|
||||
>
|
||||
<Box
|
||||
p={{ xs: 1, sm: 2 }}
|
||||
maxWidth="100%"
|
||||
overflowX="hidden"
|
||||
>
|
||||
{/* Header Buttons */}
|
||||
<Box
|
||||
display="flex"
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Box, Typography, Stack, Button, useTheme, TextField } from '@mui/materi
|
||||
import AddIcon from '@mui/icons-material/Add';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
const Budget= ({ currentStepIndex = 0, onNext, onBack }) => {
|
||||
const Budget = ({ currentStepIndex = 0, onNext, onBack }) => {
|
||||
const theme = useTheme();
|
||||
const navigate = useNavigate();
|
||||
|
||||
@@ -49,7 +49,7 @@ const Budget= ({ currentStepIndex = 0, onNext, onBack }) => {
|
||||
{/* Expansion Plans Through Cloud Kitchen (No of Branches) Input */}
|
||||
<InputField label="Expansion Plans Through Cloud Kitchen (No of Branches)" placeholder="200" theme={theme} />
|
||||
|
||||
|
||||
|
||||
|
||||
{/* Next Button */}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ const TableView = ({ data = [], onAddNewProduct }) => {
|
||||
setCurrentPage(1); // العودة للصفحة الأولى عند تغيير البحث
|
||||
};
|
||||
|
||||
const handleExportPDF = () => {
|
||||
const handleExportPDF = () => {
|
||||
const doc = new jsPDF();
|
||||
doc.setFontSize(14);
|
||||
doc.text('Top Selling Products', 14, 20);
|
||||
@@ -68,7 +68,7 @@ const TableView = ({ data = [], onAddNewProduct }) => {
|
||||
row.product,
|
||||
row.sales,
|
||||
`$${row.amount}`,
|
||||
`$${row.price}`,
|
||||
`$${row.price}`,
|
||||
row.expiration,
|
||||
row.status
|
||||
]));
|
||||
@@ -92,7 +92,7 @@ const TableView = ({ data = [], onAddNewProduct }) => {
|
||||
row.product,
|
||||
row.sales,
|
||||
`$${row.amount}`,
|
||||
`$${row.price}`,
|
||||
`$${row.price}`,
|
||||
row.expiration,
|
||||
row.status
|
||||
])
|
||||
@@ -120,8 +120,8 @@ const TableView = ({ data = [], onAddNewProduct }) => {
|
||||
overflow: 'hidden',
|
||||
boxShadow: theme.shadows[1],
|
||||
}}
|
||||
>
|
||||
{/* Header */}
|
||||
>
|
||||
{/* Header */}
|
||||
<Box
|
||||
sx={{
|
||||
|
||||
@@ -130,7 +130,7 @@ const TableView = ({ data = [], onAddNewProduct }) => {
|
||||
alignItems: { xs: 'flex-start', sm: 'center', md: 'center' },
|
||||
mb: 3,
|
||||
pl: { xs: 1, sm: 3 },
|
||||
pt:2,
|
||||
pt: 2,
|
||||
pr: { xs: 1, sm: 3 },
|
||||
flexDirection: { xs: 'column', sm: 'row', md: 'row' },
|
||||
gap: { xs: 2, sm: 0 }
|
||||
@@ -147,11 +147,11 @@ const TableView = ({ data = [], onAddNewProduct }) => {
|
||||
width={{ xs: '100%', sm: 'auto' }}
|
||||
justifyContent={{ xs: 'space-between', sm: 'flex-end' }}
|
||||
>
|
||||
{/* زر إضافة منتج جديد */}
|
||||
{/* زر إضافة منتج جديد */}
|
||||
<Button
|
||||
variant="contained"
|
||||
color="primary"
|
||||
onClick={onAddNewProduct}
|
||||
onClick={onAddNewProduct}
|
||||
sx={{
|
||||
textTransform: 'none',
|
||||
borderRadius: '8px',
|
||||
@@ -162,8 +162,8 @@ const TableView = ({ data = [], onAddNewProduct }) => {
|
||||
}}
|
||||
>
|
||||
|
||||
Add New Product
|
||||
|
||||
Add New Product
|
||||
|
||||
</Button>
|
||||
{/* زر تصدير جدول (Spreadsheet) */}
|
||||
<Button
|
||||
@@ -234,8 +234,8 @@ const TableView = ({ data = [], onAddNewProduct }) => {
|
||||
{isMobile ? '' : 'Filters'}
|
||||
</Button>
|
||||
</Box>
|
||||
|
||||
</Box>
|
||||
|
||||
</Box>
|
||||
|
||||
{/* جدول البيانات */}
|
||||
<TableContainer
|
||||
|
||||
@@ -78,7 +78,7 @@ const Setting = () => {
|
||||
<Box sx={{
|
||||
flexGrow: 1,
|
||||
width: sidebarOpen ? 'calc(100% - 40px)' : '100%',
|
||||
pt: { xs:2, sm: 3 },
|
||||
pt: { xs: 2, sm: 3 },
|
||||
overflowY: 'auto',
|
||||
pl: { xs: 2, sm: 3 },
|
||||
pb: { xs: 2, sm: 4 },
|
||||
|
||||
@@ -24,6 +24,8 @@ import {
|
||||
Logout as LogoutIcon
|
||||
} from '@mui/icons-material';
|
||||
|
||||
import authService from '../../services/authService'; // تأكد من المسار الصحيح
|
||||
|
||||
const menuItems = [
|
||||
{ text: 'Dashboard', icon: <DashboardIcon />, path: '/dashboard' },
|
||||
{ text: 'Cashier', icon: <CashierIcon />, path: '/cashier' },
|
||||
@@ -32,9 +34,8 @@ const menuItems = [
|
||||
{ text: 'Training', icon: <TrainingIcon />, path: '/training' },
|
||||
{ text: 'Analytics & Reporting', icon: <AnalyticsIcon />, path: '/analytics' },
|
||||
{ text: 'Restaurant Profile', icon: <RestaurantIcon />, path: '/profile' },
|
||||
{ text: 'Host Kitchen', icon: <HostKitchenIcon />, path: '/host-kitchen' },
|
||||
// { text: 'Host Kitchen', icon: <HostKitchenIcon />, path: '/host-kitchen' },
|
||||
{ text: 'Create Kitchen', icon: <CreateKitchenIcon />, path: '/create-kitchen' },
|
||||
|
||||
];
|
||||
|
||||
const bottomItems = [
|
||||
@@ -47,6 +48,17 @@ const Sidebar = ({ open, onClose, isMobile, drawerWidth }) => {
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
|
||||
const handleLogout = async () => {
|
||||
const result = await authService.logout();
|
||||
|
||||
localStorage.removeItem('token');
|
||||
localStorage.removeItem('refresh_token');
|
||||
|
||||
navigate('/login', { replace: true });
|
||||
|
||||
if (isMobile) onClose();
|
||||
};
|
||||
|
||||
const renderListItems = (items) =>
|
||||
items.map((item, index) => {
|
||||
const isActive = location.pathname === item.path;
|
||||
@@ -56,10 +68,11 @@ const Sidebar = ({ open, onClose, isMobile, drawerWidth }) => {
|
||||
<Box
|
||||
onClick={() => {
|
||||
if (item.text === 'Log Out') {
|
||||
localStorage.removeItem('token');
|
||||
handleLogout();
|
||||
} else {
|
||||
navigate(item.path);
|
||||
if (isMobile) onClose();
|
||||
}
|
||||
navigate(item.path);
|
||||
if (isMobile) onClose();
|
||||
}}
|
||||
sx={{
|
||||
display: 'flex',
|
||||
@@ -76,10 +89,12 @@ const Sidebar = ({ open, onClose, isMobile, drawerWidth }) => {
|
||||
},
|
||||
}}
|
||||
>
|
||||
<ListItemIcon sx={{
|
||||
color: isActive ? theme.palette.primary.main : '#A6ACB8',
|
||||
minWidth: 36
|
||||
}}>
|
||||
<ListItemIcon
|
||||
sx={{
|
||||
color: isActive ? theme.palette.primary.main : '#A6ACB8',
|
||||
minWidth: 36,
|
||||
}}
|
||||
>
|
||||
{item.icon}
|
||||
</ListItemIcon>
|
||||
<ListItemText
|
||||
@@ -87,7 +102,7 @@ const Sidebar = ({ open, onClose, isMobile, drawerWidth }) => {
|
||||
primaryTypographyProps={{
|
||||
sx: {
|
||||
color: isActive ? theme.palette.primary.main : '#61677F',
|
||||
fontSize: '0.875rem'
|
||||
fontSize: '0.875rem',
|
||||
},
|
||||
}}
|
||||
/>
|
||||
@@ -97,12 +112,14 @@ const Sidebar = ({ open, onClose, isMobile, drawerWidth }) => {
|
||||
});
|
||||
|
||||
const drawer = (
|
||||
<Box sx={{
|
||||
height: '100%',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
bgcolor: 'background.paper'
|
||||
}}>
|
||||
<Box
|
||||
sx={{
|
||||
height: '100%',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
bgcolor: 'background.paper',
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
sx={{
|
||||
px: 2,
|
||||
@@ -111,7 +128,7 @@ const Sidebar = ({ open, onClose, isMobile, drawerWidth }) => {
|
||||
position: 'sticky',
|
||||
top: 0,
|
||||
zIndex: 1,
|
||||
bgcolor: 'background.paper'
|
||||
bgcolor: 'background.paper',
|
||||
}}
|
||||
>
|
||||
<Box display="flex" alignItems="center">
|
||||
@@ -152,22 +169,26 @@ const Sidebar = ({ open, onClose, isMobile, drawerWidth }) => {
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
<Box sx={{
|
||||
flex: 1,
|
||||
overflowY: 'auto',
|
||||
scrollbarWidth: 'none',
|
||||
'&::-webkit-scrollbar': { display: 'none' },
|
||||
py: 1
|
||||
}}>
|
||||
<Box
|
||||
sx={{
|
||||
flex: 1,
|
||||
overflowY: 'auto',
|
||||
scrollbarWidth: 'none',
|
||||
'&::-webkit-scrollbar': { display: 'none' },
|
||||
py: 1,
|
||||
}}
|
||||
>
|
||||
<List>{renderListItems(menuItems)}</List>
|
||||
</Box>
|
||||
|
||||
<Box sx={{
|
||||
position: 'sticky',
|
||||
bottom: 0,
|
||||
bgcolor: 'background.paper',
|
||||
borderColor: 'divider'
|
||||
}}>
|
||||
<Box
|
||||
sx={{
|
||||
position: 'sticky',
|
||||
bottom: 0,
|
||||
bgcolor: 'background.paper',
|
||||
borderColor: 'divider',
|
||||
}}
|
||||
>
|
||||
<List>{renderListItems(bottomItems)}</List>
|
||||
</Box>
|
||||
</Box>
|
||||
@@ -192,16 +213,14 @@ const Sidebar = ({ open, onClose, isMobile, drawerWidth }) => {
|
||||
width: drawerWidth,
|
||||
boxSizing: 'border-box',
|
||||
borderRight: 'none',
|
||||
boxShadow: 'none'
|
||||
boxShadow: 'none',
|
||||
},
|
||||
}}
|
||||
>
|
||||
{drawer}
|
||||
</Drawer>
|
||||
|
||||
</Box>
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
export default Sidebar;
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم