update
This commit is contained in:
10
src/app/(withAuth)/dashboard/inquiry_privacy/fencing/page.js
Normal file
10
src/app/(withAuth)/dashboard/inquiry_privacy/fencing/page.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import InquiryPrivacyFencingPage from "@/components/dashboard/inquiryPrivacyFencing";
|
||||||
|
|
||||||
|
const Page = () => {
|
||||||
|
|
||||||
|
return (
|
||||||
|
<InquiryPrivacyFencingPage />
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Page;
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
import { Box, Stack } from "@mui/material";
|
|
||||||
import HeaderWithLogo from "@/components/layouts/dashboard/headerWithLogo";
|
import HeaderWithLogo from "@/components/layouts/dashboard/headerWithLogo";
|
||||||
import HeaderWithSidebar from "@/components/layouts/dashboard/headerWithSidebar";
|
import HeaderWithSidebar from "@/components/layouts/dashboard/headerWithSidebar";
|
||||||
import "react-toastify/dist/ReactToastify.css";
|
import { Box, Stack } from "@mui/material";
|
||||||
|
|
||||||
const Template = ({ children }) => {
|
const Layout = ({ children }) => {
|
||||||
return (
|
return (
|
||||||
<Stack>
|
<Stack>
|
||||||
<HeaderWithLogo />
|
<HeaderWithLogo />
|
||||||
@@ -12,6 +11,5 @@ const Template = ({ children }) => {
|
|||||||
</Box>
|
</Box>
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
export default Layout;
|
||||||
export default Template;
|
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
const Page = () => {
|
const Page = () => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
4
src/components/dashboard/inquiryPrivacyFencing/index.jsx
Normal file
4
src/components/dashboard/inquiryPrivacyFencing/index.jsx
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
const InquiryPrivacyFencingPage = () => {
|
||||||
|
return <></>
|
||||||
|
}
|
||||||
|
export default InquiryPrivacyFencingPage
|
||||||
@@ -7,11 +7,29 @@ import { useEffect, useReducer, useState } from "react";
|
|||||||
import { filterMenuItems } from "../utils/filterMenuItems";
|
import { filterMenuItems } from "../utils/filterMenuItems";
|
||||||
import { pageMenu } from "../utils/pageMenu";
|
import { pageMenu } from "../utils/pageMenu";
|
||||||
|
|
||||||
|
function selectPage(item, route) {
|
||||||
|
if (item.type === "page") {
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
selected: item.route === route,
|
||||||
|
showSubitems: item.route === route,
|
||||||
|
};
|
||||||
|
} else if (item.Subitems && Array.isArray(item.Subitems)) {
|
||||||
|
const updatedSubitems = item.Subitems.map(subitem => selectPage(subitem, route));
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
Subitems: updatedSubitems,
|
||||||
|
showSubitems: updatedSubitems.some(subitem => subitem.showSubitems || subitem.route === route),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
function reducer(state, action) {
|
function reducer(state, action) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case "UPDATE_MENU":
|
case "UPDATE_MENU":
|
||||||
const _permissions = action.permissions || []
|
const _permissions = action.permissions || []
|
||||||
const filteredPageMenu = filterMenuItems(pageMenu, ['all', ..._permissions])
|
const filteredPageMenu = filterMenuItems(state, ['all', ..._permissions])
|
||||||
return filteredPageMenu
|
return filteredPageMenu
|
||||||
case "COLLAPSE_MENU":
|
case "COLLAPSE_MENU":
|
||||||
return state.map((item) =>
|
return state.map((item) =>
|
||||||
@@ -62,40 +80,7 @@ function reducer(state, action) {
|
|||||||
: item;
|
: item;
|
||||||
});
|
});
|
||||||
case "SELECTED":
|
case "SELECTED":
|
||||||
return state.map((item) => {
|
return state.map(item => selectPage(item, action.route));
|
||||||
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:
|
default:
|
||||||
throw new Error();
|
throw new Error();
|
||||||
@@ -109,13 +94,15 @@ const SidebarMenu = () => {
|
|||||||
const [selectedKey, setSelectedKey] = useState(null);
|
const [selectedKey, setSelectedKey] = useState(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
dispatch({ type: "SELECTED", route: pathname });
|
||||||
|
setSelectedKey(pathname);
|
||||||
|
}, [userPermissions, pathname]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!userPermissions) return
|
||||||
dispatch({ type: 'UPDATE_MENU', permissions: userPermissions });
|
dispatch({ type: 'UPDATE_MENU', permissions: userPermissions });
|
||||||
}, [userPermissions])
|
}, [userPermissions])
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
dispatch({ type: "SELECTED", route: pathname });
|
|
||||||
setSelectedKey(pathname);
|
|
||||||
}, [pathname]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
selectedKey &&
|
selectedKey &&
|
||||||
@@ -126,11 +113,13 @@ const SidebarMenu = () => {
|
|||||||
}, [selectedKey]);
|
}, [selectedKey]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<List disablePadding dense>
|
userPermissions && (
|
||||||
{menuItems.map((menuItem) => {
|
<List disablePadding dense>
|
||||||
return <SidebarListItems dispatch={dispatch} key={menuItem.id} menuItem={menuItem} />;
|
{menuItems.map((menuItem) => {
|
||||||
})}
|
return <SidebarListItems dispatch={dispatch} key={menuItem.id} menuItem={menuItem} />;
|
||||||
</List>
|
})}
|
||||||
|
</List>
|
||||||
|
)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
export default SidebarMenu;
|
export default SidebarMenu;
|
||||||
|
|||||||
@@ -195,6 +195,36 @@ export const pageMenu = [
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: "inquiryPrivacyManagment",
|
||||||
|
label: "استعلام حریم راه",
|
||||||
|
type: "menu",
|
||||||
|
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
|
||||||
|
hasSubitems: true,
|
||||||
|
Subitems: [
|
||||||
|
{
|
||||||
|
id: "inquiryPrivacyManagmentFencing",
|
||||||
|
label: "احداث و بهره برداری دیوارکشی و مستحدثات",
|
||||||
|
type: "page",
|
||||||
|
route: prefix + "/dashboard/inquiry_privacy/fencing",
|
||||||
|
permissions: ['all']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "inquiryPrivacyManagmentRoad",
|
||||||
|
label: "احداث راه دسترسی اختصاصی",
|
||||||
|
type: "page",
|
||||||
|
route: prefix + "/dashboard/inquiry_privacy/road",
|
||||||
|
permissions: ['all']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "inquiryPrivacyManagmentInfrastructure",
|
||||||
|
label: "احداث و بهره برداری تاسیسات زیربنایی",
|
||||||
|
type: "page",
|
||||||
|
route: prefix + "/dashboard/inquiry_privacy/infrastructure",
|
||||||
|
permissions: ['all']
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: "safetyAndPrivacyManagment",
|
id: "safetyAndPrivacyManagment",
|
||||||
label: "نگهداری حریم راه",
|
label: "نگهداری حریم راه",
|
||||||
|
|||||||
Reference in New Issue
Block a user