This commit is contained in:
Amirhossein Mahmoodi
2024-07-08 15:45:39 +03:30
parent 20a0b2984c
commit 6288ac926c
14 changed files with 853 additions and 403 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 468.85 509.45"><defs><style>.cls-1{fill:#ed8a23;}.cls-2{fill:#4962ad;}</style></defs><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><polygon class="cls-1" points="122.85 98.5 122.85 154.2 133.75 143.8 192.85 183.7 192.85 98.3 122.85 98.5"/><polygon class="cls-1" points="212.05 56.5 211.35 193.7 241.55 213.2 285.05 180.5 285.55 55.7 212.05 56.5"/><polygon class="cls-1" points="304.45 0.8 304.85 167.5 374.45 114.9 374.35 0 304.45 0.8"/><path class="cls-1" d="M387.85,233.4A24,24,0,1,0,353,254.8a144.82,144.82,0,0,1-232.2,103.3,145.22,145.22,0,0,1-55.4-94.3l-8,6.7-12-14.3a163.44,163.44,0,0,0,56.3,110.9L98,371.4h0l-11.3,14.7A11.71,11.71,0,0,0,71,388.7L4.45,475a21.39,21.39,0,1,0,33.9,26.1l66.5-86.3a11.87,11.87,0,0,0-1-15.5l11.5-14.9h0l3.1-4.7a163.17,163.17,0,0,0,90.1,27.1h0a163.57,163.57,0,0,0,163.5-150.9A23.78,23.78,0,0,0,387.85,233.4Z"/><polygon class="cls-2" points="468.85 83.1 383.35 93.6 400.45 116.3 241.55 235 133.55 163.9 38.95 240.2 40.85 242.4 57.95 262.7 69.75 252.9 133.95 198.7 241.55 271 417.55 139 435.15 162.4 468.85 83.1"/></g></g></svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

3
src/app/default.js Normal file
View File

@@ -0,0 +1,3 @@
export default function Default() {
return null
}

View File

@@ -1,8 +1,8 @@
'use client'
import HomeComponent from "@/components/home";
import { redirect } from "next/navigation"
function Page() {
return <HomeComponent/>;
redirect('/dashboard', 'replace')
return null
}
export default Page;
export default Page

View File

@@ -0,0 +1,40 @@
"use client";
import { Stack, Typography } from "@mui/material";
import Image from "next/image";
const HeaderBottom = () => {
return (
<Stack
sx={{
px: 2,
py: 1,
background: (theme) => theme.palette.primary2.main,
}}
spacing={4}
alignItems={"center"}
direction={"row"}
>
<Image
alt=""
priority
src={"/images/rmsLogo.svg"}
width={65}
height={71}
/>
<Stack alignItems={"center"} spacing={1}>
<Typography
variant="h5"
sx={{ color: (theme) => theme.palette.primary2.contrastText }}
>
سامانه جامع راهداری
</Typography>
<Typography
sx={{ color: (theme) => theme.palette.primary2.contrastText }}
>
rms.rmto.ir
</Typography>
</Stack>
</Stack>
);
};
export default HeaderBottom;

View File

@@ -0,0 +1,17 @@
import { Stack } from "@mui/material";
import Image from "next/image";
const HeaderTop = () => {
return (
<Stack sx={{ p: 2 }}>
<Image
alt=""
priority
src={"/images/headerLogo.png"}
width={190}
height={44}
/>
</Stack>
);
};
export default HeaderTop;

View File

@@ -1,9 +1,13 @@
import {Box, Stack} from "@mui/material";
import { Box, Stack } from "@mui/material";
import HeaderTop from "./HaederTop";
import HeaderBottom from "./HaederBottom";
const HeaderWithLogo = () => {
return (<Stack>
<Box>header1</Box>
<Box>header2</Box>
</Stack>)
}
export default HeaderWithLogo
return (
<Stack>
<HeaderTop />
<HeaderBottom />
</Stack>
);
};
export default HeaderWithLogo;

View File

@@ -0,0 +1,4 @@
const HeaderMenu = () => {
return <>منو</>;
};
export default HeaderMenu;

View File

@@ -1,94 +1,116 @@
'use client'
import {useState} from "react";
import {Box, Drawer, IconButton, Paper, styled, Toolbar, Typography} from "@mui/material";
import MuiAppBar from '@mui/material/AppBar';
import MenuIcon from '@mui/icons-material/Menu';
import ChevronRightIcon from '@mui/icons-material/ChevronRight';
"use client";
import SidebarMenu from "@/core/components/SidebarMenu";
import ChevronRightIcon from "@mui/icons-material/ChevronRight";
import MenuIcon from "@mui/icons-material/Menu";
import { Box, Drawer, IconButton, Paper, styled, Toolbar } from "@mui/material";
import MuiAppBar from "@mui/material/AppBar";
import { useState } from "react";
import HeaderMenu from "./HeaderMenu";
const drawerWidth = 260;
const drawerWidth = 300;
const Main = styled(Paper, {shouldForwardProp: (prop) => prop !== 'open'})(({theme, open}) => ({
flexGrow: 1, transition: theme.transitions.create('margin', {
easing: theme.transitions.easing.sharp, duration: theme.transitions.duration.leavingScreen,
}), marginLeft: `-${drawerWidth}px`, ...(open && {
transition: theme.transitions.create('margin', {
easing: theme.transitions.easing.easeOut, duration: theme.transitions.duration.enteringScreen,
}), marginLeft: 0,
const Main = styled(Paper, { shouldForwardProp: (prop) => prop !== "open" })(
({ theme, open }) => ({
flexGrow: 1,
transition: theme.transitions.create("margin", {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.leavingScreen,
}),
}),);
marginLeft: `-${drawerWidth}px`,
...(open && {
transition: theme.transitions.create("margin", {
easing: theme.transitions.easing.easeOut,
duration: theme.transitions.duration.enteringScreen,
}),
marginLeft: 0,
}),
})
);
const AppBar = styled(MuiAppBar, {
shouldForwardProp: (prop) => prop !== 'open',
})(({theme, open}) => ({
transition: theme.transitions.create(['margin', 'width'], {
easing: theme.transitions.easing.sharp, duration: theme.transitions.duration.leavingScreen,
}), ...(open && {
width: `calc(100% - ${drawerWidth}px)`,
marginLeft: `${drawerWidth}px`,
transition: theme.transitions.create(['margin', 'width'], {
easing: theme.transitions.easing.easeOut, duration: theme.transitions.duration.enteringScreen,
}),
shouldForwardProp: (prop) => prop !== "open",
})(({ theme, open }) => ({
transition: theme.transitions.create(["margin", "width"], {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.leavingScreen,
}),
...(open && {
width: `calc(100% - ${drawerWidth}px)`,
marginLeft: `${drawerWidth}px`,
transition: theme.transitions.create(["margin", "width"], {
easing: theme.transitions.easing.easeOut,
duration: theme.transitions.duration.enteringScreen,
}),
}),
}));
const DrawerHeader = styled('div')(({theme}) => ({
display: 'flex', alignItems: 'center', padding: theme.spacing(0, 1), // necessary for content to be below app bar
...theme.mixins.toolbar, justifyContent: 'flex-end',
const DrawerHeader = styled("div")(({ theme }) => ({
display: "flex",
alignItems: "center",
padding: theme.spacing(0, 1),
...theme.mixins.toolbar,
justifyContent: "flex-end",
}));
const HeaderWithSidebar = ({children}) => {
const [open, setOpen] = useState(false);
const HeaderWithSidebar = ({ children }) => {
const [open, setOpen] = useState(true);
const handleDrawerOpen = () => {
setOpen(true);
};
const handleDrawerClose = () => {
setOpen(false);
};
return (<Box sx={{display: 'flex'}}>
<AppBar sx={{position: 'fixed', top: "unset"}} elevation={0} open={open}>
<Toolbar>
<IconButton
color="inherit"
aria-label="open drawer"
onClick={handleDrawerOpen}
edge="start"
sx={{mr: 2, ...(open && {display: 'none'})}}
>
<MenuIcon/>
</IconButton>
<Typography variant="h6" noWrap component="div">
menu
</Typography>
</Toolbar>
</AppBar>
<Drawer
sx={{
width: drawerWidth, flexShrink: 0, '& .MuiDrawer-paper': {
width: drawerWidth,
boxSizing: 'border-box',
borderTop: 1,
borderTopColor: 'divider',
top: "unset"
},
}}
variant="persistent"
anchor="left"
open={open}
>
<DrawerHeader>
<IconButton onClick={handleDrawerClose}>
<ChevronRightIcon/>
</IconButton>
</DrawerHeader>
<SidebarMenu />
</Drawer>
<Main elevation={0} open={open}>
<DrawerHeader/>
{children}
</Main>
</Box>)
}
export default HeaderWithSidebar
const handleDrawerOpen = () => {
setOpen(true);
};
const handleDrawerClose = () => {
setOpen(false);
};
return (
<Box sx={{ display: "flex" }}>
<AppBar
sx={{ position: "fixed", top: "unset" }}
elevation={0}
open={open}
>
<Toolbar variant="dense">
<IconButton
color="inherit"
aria-label="open drawer"
onClick={handleDrawerOpen}
edge="start"
sx={{ mr: 2, ...(open && { display: "none" }) }}
>
<MenuIcon />
</IconButton>
<Box sx={{ flexGrow: 1, display: { xs: "none", md: "flex" } }}>
<HeaderMenu />
</Box>
</Toolbar>
</AppBar>
<Drawer
sx={{
width: drawerWidth,
flexShrink: 0,
"& .MuiDrawer-paper": {
width: drawerWidth,
boxSizing: "border-box",
borderTop: 1,
borderTopColor: "divider",
top: "unset",
},
}}
variant="persistent"
anchor="left"
open={open}
>
<DrawerHeader>
<IconButton onClick={handleDrawerClose}>
<ChevronRightIcon />
</IconButton>
</DrawerHeader>
<SidebarMenu />
</Drawer>
<Main elevation={0} open={open}>
<DrawerHeader />
{children}
</Main>
</Box>
);
};
export default HeaderWithSidebar;

View File

@@ -1,46 +1,77 @@
import {Collapse, ListItem, ListItemButton, ListItemIcon, ListItemText} from "@mui/material";
import { ExpandLess, ExpandMore } from '@mui/icons-material';
import WifiIcon from '@mui/icons-material/Wifi';
import SidebarSubitems from "@/core/components/SidebarSubitems";
import { ExpandLess, ExpandMore } from "@mui/icons-material";
import {
Collapse,
List,
ListItem,
ListItemButton,
ListItemIcon,
ListItemText,
} from "@mui/material";
import Link from "next/link";
const SidebarListItems = ({menuItem, dispatch}) => {
return(
<>
<ListItem disablePadding sx={{p : 0}}>
<ListItemButton sx={{
'&.Mui-selected': {
backgroundColor: 'rgba(0, 0, 0, 0.2)',
},
}} selected={menuItem.selected} onClick={() => {
dispatch({type: "COLLAPSE_MENU", id: menuItem.id})
}}>
<ListItemIcon
sx={{
minWidth: 0,
justifyContent: "center",
color: "primary.main",
width: 40,
height: 24,
pr: 2,
}}
>
{menuItem.icon}
</ListItemIcon>
<ListItemText primary={menuItem.id} />
{menuItem.hasSubitems ? (menuItem.showSubitems ? <ExpandLess /> : <ExpandMore />) : null }
</ListItemButton>
</ListItem>
<Collapse in={menuItem.showSubitems} timeout="auto" mountOnEnter={true} unmountOnExit={true}>
{
menuItem.hasSubitems ? (menuItem.Subitems.map((subitem,index)=>{
return(
<SidebarSubitems dispatch={dispatch} key={index} subitem={subitem}/>
)
})) : null
}
</Collapse>
</>
)
}
export default SidebarListItems
const SidebarListItems = ({ menuItem, dispatch }) => {
return (
<>
<ListItem disablePadding divider>
<ListItemButton
sx={{ py: 1, px: 0.5 }}
disableGutters
selected={menuItem.selected}
component={menuItem.type === "page" ? Link : null}
href={menuItem.type === "page" ? menuItem.route : null}
onClick={() => {
dispatch({ type: "COLLAPSE_MENU", id: menuItem.id });
}}
>
<ListItemIcon
sx={{
minWidth: 0,
justifyContent: "center",
color: "primary.main",
width: 40,
height: 24,
}}
>
{menuItem.icon}
</ListItemIcon>
<ListItemText primary={menuItem.label} />
{menuItem.hasSubitems ? (
menuItem.showSubitems ? (
<ExpandLess />
) : (
<ExpandMore />
)
) : null}
</ListItemButton>
</ListItem>
<Collapse
in={menuItem.showSubitems}
timeout="auto"
mountOnEnter={true}
unmountOnExit={true}
>
{menuItem.hasSubitems ? (
<List
disablePadding
dense
sx={{
background: "#00000008",
}}
>
{menuItem.Subitems.map((subitem, index) => {
return (
<SidebarSubitems
key={index}
dispatch={dispatch}
subitem={subitem}
/>
);
})}
</List>
) : null}
</Collapse>
</>
);
};
export default SidebarListItems;

View File

@@ -1,201 +1,132 @@
"use client"
import {List} from "@mui/material";
"use client";
import SidebarListItems from "@/core/components/SidebarListItems";
import {useEffect, useReducer, useState} from "react";
import {usePathname} from 'next/navigation'
import SecurityIcon from '@mui/icons-material/Security';
import SpaceDashboardIcon from "@mui/icons-material/SpaceDashboard";
import AssessmentIcon from '@mui/icons-material/Assessment';
import AirlineSeatReclineNormalIcon from "@mui/icons-material/AirlineSeatReclineNormal";
import RepartitionIcon from '@mui/icons-material/Repartition';
const data = [
{
id: "hello",
type: "menu",
route: "/hello",
icon: <SecurityIcon sx={{width: 'inherit', height: 'inherit'}}/>,
selected: false,
Subitems: [
{
id: "amin",
route: "/s",
icon: <SpaceDashboardIcon sx={{width: 'inherit', height: 'inherit'}}/>,
firstName: "amin",
lastName: "ali",
Subitems: [
{
id: "shahrokh", shahrokh: "shahrokh", type: "page", selected: false, route: "/dashbssoard", icon: <AssessmentIcon sx={{width: 'inherit', height: 'inherit'}}/>
},
{
id: "shasdasdsahrokh", shahrokh: "shahroasdasdkh", type: "page", selected: false, route: "/dashboardsd", icon: <AirlineSeatReclineNormalIcon sx={{width: 'inherit', height: 'inherit'}}/>
}
],
hasSubitems: true,
showSubitems: false,
type: "menu",
selected: false,
},
{
id: "amir",
route: "/dashboarsad",
icon: <RepartitionIcon sx={{width: 'inherit', height: 'inherit'}}/>,
firstName: "amir",
lastName: "akbar",
hasSubitems: false,
showSubitems: false,
selected: false,
type: "page",
},
],
hasSubitems: true,
showSubitems: false
},
{
id: "hi",
type: "menu",
icon: <SecurityIcon sx={{width: 'inherit', height: 'inherit'}}/>,
route: "/hi",
selected: false,
Subitems: [
{
id: "ali",
route: "/dashboardss",
firstName: "ali",
lastName: "ali",
icon: <SecurityIcon sx={{width: 'inherit', height: 'inherit'}}/>,
hasSubitems: false,
showSubitems: false,
type: "page",
selected: false,
},
{
id: "akbar",
route: "/akbar",
firstName: "akbar",
icon: <SecurityIcon sx={{width: 'inherit', height: 'inherit'}}/>,
lastName: "akbar",
hasSubitems: false,
showSubitems: false,
type: "page",
selected: false,
},
],
hasSubitems: true,
showSubitems: false
},
{
id: "hoo",
type: "page",
route: "/dashboard",
icon: <SecurityIcon sx={{width: 'inherit', height: 'inherit'}}/>,
selected: false,
hasSubitems: false,
showSubitems: false
}
]
import { List } from "@mui/material";
import { usePathname } from "next/navigation";
import { useEffect, useReducer, useState } from "react";
import { pageMenu } from "../utils/pageMenu";
function reducer(state, action) {
switch (action.type) {
case "COLLAPSE_MENU":
return state.map((item) => action.id == item.id ? {
...item, showSubitems: !item.showSubitems
} : item)
case "COLLAPSE_SUB_ITEMS" :
return state.map((item) => {
return item.hasSubitems ? {
...item, Subitems: item.Subitems.map((subitem) => action.id === subitem.id ? {
...subitem, showSubitems: !subitem.showSubitems
} : subitem)
} : item
})
case "COLLAPSE_SUB_SECOND_ITEMS" :
return state.map((item) => {
return item.hasSubitems ? {
...item, Subitems: item.Subitems.map((subitem) => {
return subitem.hasSubitems ? {
...subitem,
Subitems: subitem.Subitems.map((secondSubitem) => action.id === secondSubitem.id ? {
...secondSubitem, showSubitems: !secondSubitem.showSubitems
} : secondSubitem)
} : subitem
})
} : item
})
case "SELECTED":
return state.map((item) => {
return item.type === "page" ? {
...item, selected: action.route === item.route,showSubitems: item.route === action.route
} : item.Subitems && Array.isArray(item.Subitems) ? {
...item, Subitems: item.Subitems.map((subitem) => {
return subitem.type === "page" ? {
...subitem, selected: action.route === subitem.route,showSubitems: subitem.route === action.route
} : subitem.Subitems && Array.isArray(subitem.Subitems) ? {
...subitem, Subitems: subitem.Subitems.map((secondSubItem) => ({
...secondSubItem, selected: secondSubItem.route === action.route
})),showSubitems: subitem.Subitems.some((secondSubItem) => secondSubItem.route === action.route),
} : subitem
}),showSubitems: item.Subitems.some((subitem) => subitem.showSubitems),
} : item
});
// case "SELECTED":
// return state.map((item) => {
// return item.type === "page" ? {
// ...item,
// selected: action.route === item.route
// } : item.Subitems && Array.isArray(item.Subitems) ? {
// ...item,
// Subitems: item.Subitems.map((subitem) => {
// const updatedSubitem = subitem.type === "page" ? {
// ...subitem,
// selected: action.route === subitem.route
// } : subitem.Subitems && Array.isArray(subitem.Subitems) ? {
// ...subitem,
// Subitems: subitem.Subitems.map((secondSubItem) => ({
// ...secondSubItem,
// selected: secondSubItem.route === action.route
// })),
// showSubitems: subitem.Subitems.some((secondSubItem) => secondSubItem.route === action.route),
// } : subitem;
//
// console.log("Updated subitem:", updatedSubitem); // Log the updated subitem
// return updatedSubitem;
// }),
// showSubitems: item.Subitems.some((subitem) => subitem.showSubitems),
// } : item
// });
switch (action.type) {
case "COLLAPSE_MENU":
return state.map((item) =>
action.id == item.id
? {
...item,
showSubitems: !item.showSubitems,
}
: item
);
case "COLLAPSE_SUB_ITEMS":
return state.map((item) => {
return item.hasSubitems
? {
...item,
Subitems: item.Subitems.map((subitem) =>
action.id === subitem.id
? {
...subitem,
showSubitems: !subitem.showSubitems,
}
: subitem
),
}
: item;
});
case "COLLAPSE_SUB_SECOND_ITEMS":
return state.map((item) => {
return item.hasSubitems
? {
...item,
Subitems: item.Subitems.map((subitem) => {
return subitem.hasSubitems
? {
...subitem,
Subitems: subitem.Subitems.map((secondSubitem) =>
action.id === secondSubitem.id
? {
...secondSubitem,
showSubitems: !secondSubitem.showSubitems,
}
: secondSubitem
),
}
: subitem;
}),
}
: item;
});
case "SELECTED":
return state.map((item) => {
return item.type === "page"
? {
...item,
selected: action.route === item.route,
showSubitems: item.route === action.route,
}
: item.Subitems && Array.isArray(item.Subitems)
? {
...item,
Subitems: item.Subitems.map((subitem) => {
return subitem.type === "page"
? {
...subitem,
selected: action.route === subitem.route,
showSubitems: subitem.route === action.route,
}
: subitem.Subitems && Array.isArray(subitem.Subitems)
? {
...subitem,
Subitems: subitem.Subitems.map((secondSubItem) => ({
...secondSubItem,
selected: secondSubItem.route === action.route,
})),
showSubitems: subitem.Subitems.some(
(secondSubItem) => secondSubItem.route === action.route
),
}
: subitem;
}),
showSubitems: item.Subitems.some(
(subitem) => subitem.showSubitems
),
}
: item;
});
default:
throw new Error();
}
default:
throw new Error();
}
}
const SidebarMenu = () => {
const [menuItems, dispatch] = useReducer(reducer, data);
const pathname = usePathname()
const [selectedKey, setSelectedKey] = useState(null);
useEffect(() => {
dispatch({type: "SELECTED", route: pathname});
setSelectedKey(pathname);
}, [pathname]);
const [menuItems, dispatch] = useReducer(reducer, pageMenu);
const pathname = usePathname();
const [selectedKey, setSelectedKey] = useState(null);
useEffect(() => {
dispatch({ type: "SELECTED", route: pathname });
setSelectedKey(pathname);
}, [pathname]);
useEffect(() => {
selectedKey && document.querySelector(`[data-route="${selectedKey}"]`)?.scrollIntoView({
behavior: "smooth", block: "center"
});
}, [selectedKey]);
useEffect(() => {
selectedKey &&
document.querySelector(`[data-route="${selectedKey}"]`)?.scrollIntoView({
behavior: "smooth",
block: "center",
});
}, [selectedKey]);
return (
<List disablePadding>
{
menuItems.map((menuItem) => {
return (
<SidebarListItems dispatch={dispatch} key={menuItem.id} menuItem={menuItem}/>
)
})
}
</List>
)
}
export default SidebarMenu
return (
<List disablePadding dense>
{menuItems.map((menuItem) => {
return (
<SidebarListItems
dispatch={dispatch}
key={menuItem.id}
menuItem={menuItem}
/>
);
})}
</List>
);
};
export default SidebarMenu;

View File

@@ -1,74 +1,75 @@
import {Collapse, List, ListItem, ListItemButton, ListItemIcon, ListItemText} from "@mui/material";
import {ExpandLess, ExpandMore} from "@mui/icons-material";
import { ExpandLess, ExpandMore } from "@mui/icons-material";
import {
Collapse,
List,
ListItem,
ListItemButton,
ListItemIcon,
ListItemText,
} from "@mui/material";
import Link from "next/link";
const SidebarSubitems = ({subitem, dispatch}) => {
return (
<>
<List disablePadding>
<ListItem disablePadding>
<ListItemButton sx={{
'&.Mui-selected': {
backgroundColor: 'rgba(0, 0, 0, 0.1)',
},
}} selected={subitem.selected} onClick={() => {
dispatch({type: "COLLAPSE_SUB_ITEMS", id: subitem.id})
}}>
<ListItemIcon
sx={{
minWidth: 0,
justifyContent: "center",
color: "primary.main",
width: 40,
height: 24,
pr: 2,
}}
>
{subitem.icon}
</ListItemIcon>
<ListItemText primary={subitem.firstName}/>
{subitem.hasSubitems ? (subitem.showSubitems ? <ExpandLess/> : <ExpandMore/>) : null
}
</ListItemButton>
</ListItem>
</List>
{
subitem.hasSubitems ? (subitem.Subitems.map((subSubitem, index) => {
return (
<Collapse key={index} in={subitem.showSubitems} timeout="auto" mountOnEnter={true} unmountOnExit={true}>
<List disablePadding>
<ListItem disablePadding>
<ListItemButton
onClick={() => {
dispatch({type: "COLLAPSE_SUB_SECOND_ITEMS", id: subSubitem.id})
}}
selected={subSubitem.selected}
sx={{
'&.Mui-selected': {
backgroundColor: 'rgba(0, 0, 0, 0.05)',
},
}}
>
<ListItemIcon
sx={{
minWidth: 0,
justifyContent: "center",
color: "primary.main",
width: 40,
height: 24,
pr: 2,
}}
>
{subSubitem.icon}
</ListItemIcon>
<ListItemText primary={subSubitem.shahrokh}/>
</ListItemButton>
</ListItem>
</List>
</Collapse>
)
})) : null
}
</>
)
}
export default SidebarSubitems
const SidebarSubitems = ({ subitem, dispatch }) => {
return (
<>
<ListItem disablePadding divider>
<ListItemButton
disableGutters
sx={{ py: 1, px: 0.5, pl: 1 }}
selected={subitem.selected}
component={subitem.type === "page" ? Link : null}
href={subitem.type === "page" ? subitem.route : null}
onClick={() => {
dispatch({ type: "COLLAPSE_SUB_ITEMS", id: subitem.id });
}}
>
<ListItemIcon
sx={{
minWidth: 0,
justifyContent: "center",
width: 40,
height: 24,
}}
>
{subitem.icon}
</ListItemIcon>
<ListItemText primary={subitem.label} />
{subitem.hasSubitems ? (
subitem.showSubitems ? (
<ExpandLess />
) : (
<ExpandMore />
)
) : null}
</ListItemButton>
</ListItem>
<Collapse
in={subitem.showSubitems}
timeout="auto"
mountOnEnter={true}
unmountOnExit={true}
>
{subitem.hasSubitems ? (
<List
disablePadding
dense
sx={{
background: "#00000008",
}}
>
{subitem.Subitems.map((subSubitem, index) => {
return (
<SidebarSubitems
key={index}
dispatch={dispatch}
subitem={subSubitem}
/>
);
})}
</List>
) : null}
</Collapse>
</>
);
};
export default SidebarSubitems;

386
src/core/utils/pageMenu.js Normal file
View File

@@ -0,0 +1,386 @@
import { AirlineSeatReclineNormal, Assessment, Repartition, Security, SpaceDashboard } from "@mui/icons-material";
export const pageMenu = [
{
id: 'dashboard',
label: 'پیشخوان',
type: "page",
route: "/dashboard",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
},
{
id: 'userManagement',
label: 'مدیریت کاربران',
type: "page",
route: "./v2/user_management",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
},
{
id: 'projectsManagment',
label: 'پروژه های راهداری',
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
hasSubitems: true,
Subitems: [
{
id: 'projectsManagmentFinance',
label: 'ثبت قرارداد و پروژه',
type: "page",
route: "./v2/rahdari_projects/finance",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
},
{
id: 'projectsManagmentList',
label: 'لیست پروژه ها',
type: "page",
route: "./v2/rahdari_projects/projects_list",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
},
{
id: 'projectsManagmentProposal',
label: 'پروژه های پیشنهادی',
type: "page",
route: "./v2/rahdari_projects/proposal",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
},
{
id: 'projectsManagmentLawmaker',
label: 'درخواست نمایندگان',
type: "page",
route: "./v2/rahdari_projects/lawmakers",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
},
{
id: 'projectsManagmentMap',
label: 'پراکندگی بر روی نقشه',
type: "page",
route: "./v2/map?type=rahdari_projects",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
},
]
},
{
id: 'roadItemManagment',
label: 'فعالیت های روزانه',
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
hasSubitems: true,
Subitems: [
{
id: 'roadItemManagmentSupervisor',
label: 'ارزیابی',
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
hasSubitems: true,
Subitems: [
{
id: 'roadItemManagmentSupervisorCartable',
label: 'کارتابل',
type: "page",
route: "./v2/road_items/supervisor/cartable",
},
]
},
{
id: 'roadItemManagmentOparation',
label: 'عملیات',
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
hasSubitems: true,
Subitems: [
{
id: 'roadItemManagmentOparationCreate',
label: 'ثبت فعالیت',
type: "page",
route: "./v2/road_items/operator/create",
},
{
id: 'roadItemManagmentOparationCartable',
label: 'کارتابل',
type: "page",
route: "./v2/road_items/operator/cartable",
},
]
},
{
id: 'roadItemManagmentMap',
label: 'پراکندگی بر روی نقشه',
type: "page",
route: "./v2/map?type=road_items",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
},
{
id: 'roadItemManagmentReport',
label: 'گزارش ها',
type: "page",
route: "./v2/road_items/report",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
},
]
},
{
id: 'roadPatrolManagment',
label: 'گشت راهداری و ترابری',
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
hasSubitems: true,
Subitems: [
{
id: 'roadPatrolManagmentSupervisor',
label: 'ارزیابی',
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
hasSubitems: true,
Subitems: [
{
id: 'roadPatrolManagmentSupervisorCartable',
label: 'کارتابل',
type: "page",
route: "./road_patrols/supervisor/cartable",
},
]
},
{
id: 'roadPatrolManagmentOparation',
label: 'عملیات',
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
hasSubitems: true,
Subitems: [
{
id: 'roadPatrolManagmentOparationCreate',
label: 'ثبت اقدام',
type: "page",
route: "./v2/road_patrols/operator/create",
},
{
id: 'roadPatrolManagmentOparationCartable',
label: 'کارتابل',
type: "page",
route: "./v2/road_patrols/operator/cartable",
},
]
},
{
id: 'roadPatrolManagmentMap',
label: 'پراکندگی بر روی نقشه',
type: "page",
route: "./v2/map?type=road_patrols",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
},
{
id: 'roadPatrolManagmentReport',
label: 'گزارش ها',
type: "page",
route: "./v2/road_patrols/report",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
},
]
},
{
id: 'safetyAndPrivacyManagment',
label: 'نگهداری حریم راه',
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
hasSubitems: true,
Subitems: [
{
id: 'safetyAndPrivacyManagmentOparation',
label: 'عملیات',
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
hasSubitems: true,
Subitems: [
{
id: 'safetyAndPrivacyManagmentOparationCreate',
label: 'ثبت فعالیت',
type: "page",
route: "./safety_and_privacy/operator/first_step",
},
{
id: 'safetyAndPrivacyManagmentOparationCartable',
label: 'کارتابل',
type: "page",
route: "./v2/safety_and_privacy/operator/cartable",
},
]
},
{
id: 'safetyAndPrivacyManagmentMap',
label: 'پراکندگی بر روی نقشه',
type: "page",
route: "./v2/map?type=safety_and_privacy",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
},
{
id: 'safetyAndPrivacyManagmentReport',
label: 'گزارش ها',
type: "page",
route: "./v2/safety_and_privacy/report",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
},
]
},
{
id: 'roadObservationsManagment',
label: 'واکنش سریع',
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
hasSubitems: true,
Subitems: [
{
id: 'roadObservationsManagmentSupervisor',
label: 'ارزیابی',
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
hasSubitems: true,
Subitems: [
{
id: 'roadObservationsManagmentSupervisorCartable',
label: 'کارتابل',
type: "page",
route: "./v2/road_observations/supervisor/cartable",
},
]
},
{
id: 'roadObservationsManagmentList',
label: 'رسیدگی به شکایات',
type: "page",
route: "./v2/road_observations",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
},
{
id: 'roadObservationsManagmentOparation',
label: 'عملیات',
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
hasSubitems: true,
Subitems: [
{
id: 'roadObservationsManagmentOparationCartable',
label: 'کارتابل',
type: "page",
route: "./v2/road_observations/operator/cartable",
},
]
},
{
id: 'roadObservationsManagmentMap',
label: 'پراکندگی بر روی نقشه',
type: "page",
route: "./v2/map?type=road_observations",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
},
{
id: 'roadObservationsManagmentReport',
label: 'گزارش ها',
type: "page",
route: "./v2/road_observations/report/index",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
},
]
},
{
id: 'winterCampManagment',
label: 'قرارگاه زمستانی',
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
hasSubitems: true,
Subitems: [
{
id: 'winterCampManagmentBlocking',
label: 'محور های انسدادی',
type: "page",
route: "./v2/winter_camp",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
},
{
id: 'winterCampManagmentFirstRing',
label: 'محور های حلقه اول',
type: "page",
route: "./v2/map?type=camp",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
},
{
id: 'winterCampManagmentReport',
label: 'گزارش ها',
type: "page",
route: "./v2/map?type=campNew",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
},
]
},
{
id: 'receiptManagment',
label: 'خسارات وارده بر ابنیه فنی و تاسیسات راه',
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
hasSubitems: true,
Subitems: [
{
id: 'receiptManagmentOparation',
label: 'عملیات',
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
hasSubitems: true,
Subitems: [
{
id: 'receiptManagmentOparationCartable',
label: 'کارتابل',
type: "page",
route: "./v2/receipt",
},
]
},
{
id: 'receiptManagmentReport',
label: 'گزارش ها',
type: "page",
route: "./v2/receipt/report",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
},
]
}
// {
// id: "hello",
// type: "menu",
// route: "/hello",
// icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
// selected: false,
// Subitems: [
// {
// id: "amin",
// route: "/s",
// icon: <SpaceDashboard sx={{ width: 'inherit', height: 'inherit' }} />,
// firstName: "amin",
// lastName: "ali",
// Subitems: [
// {
// id: "shahrokh", shahrokh: "shahrokh", type: "page", selected: false, route: "/dashbssoard", icon: <Assessment sx={{ width: 'inherit', height: 'inherit' }} />
// },
// {
// id: "shasdasdsahrokh", shahrokh: "shahroasdasdkh", type: "page", selected: false, route: "/dashboardsd", icon: <AirlineSeatReclineNormal sx={{ width: 'inherit', height: 'inherit' }} />
// }
// ],
// hasSubitems: true,
// showSubitems: false,
// type: "menu",
// selected: false,
// },
// {
// id: "amir",
// route: "/dashboarsad",
// icon: <Repartition sx={{ width: 'inherit', height: 'inherit' }} />,
// firstName: "amir",
// lastName: "akbar",
// hasSubitems: false,
// showSubitems: false,
// selected: false,
// type: "page",
// },
// ],
// hasSubitems: true,
// showSubitems: false
// },
]

View File

@@ -1,5 +1,5 @@
'use client'
import {createTheme} from "@mui/material";
import { createTheme } from "@mui/material";
const theme = createTheme({
direction: 'rtl',
@@ -7,6 +7,16 @@ const theme = createTheme({
fontFamily: `IRANSansFaNum, sans-serif`,
fontSize: 12
},
palette: {
primary: {
main: '#2070af',
contrastText: '#fff'
},
primary2: {
main: '#015688',
contrastText: '#fff'
},
}
});
export default theme