add loan request/change structure and documentary/ making middle ware for user type/update breadcrumb

This commit is contained in:
2023-08-19 13:38:51 +03:30
parent dd239ac46c
commit fd1a6bcf2e
18 changed files with 382 additions and 156 deletions

View File

@@ -3,11 +3,13 @@ import {Box, Breadcrumbs} from "@mui/material";
import {useTheme} from "@mui/material/styles";
import {NavigateBefore, NavigateNext} from "@mui/icons-material";
import BreadcrumbItem from "./BreadcrumbItem";
import useUser from "@/lib/app/hooks/useUser";
const BreadCrumbs = (props) => {
const {isVisible} = props;
const theme = useTheme();
const router = useRouter();
const {user} = useUser();
if (!isVisible) {
return null;
@@ -16,6 +18,17 @@ const BreadCrumbs = (props) => {
const {pathname} = router;
const RouterArray = pathname.split("/").filter((segment) => segment !== "");
// every part of your router you want to remove add it to this array
const segmentsToRemove = ["navgan", "refahi"];
segmentsToRemove.forEach((segmentToRemove) => {
const index = RouterArray.indexOf(segmentToRemove);
if (index !== -1) {
RouterArray.splice(index, 1);
}
});
if (RouterArray.length === 1) {
return null;
}

View File

@@ -3,6 +3,7 @@ import {Fragment, useEffect, useReducer} from "react";
import SidebarListItem from "./SidebarListItem";
import sidebarMenu from "@/core/data/sidebarMenu";
import {useRouter} from "next/router";
import useUser from "@/lib/app/hooks/useUser";
function reducer(state, action) {
switch (action.type) {
@@ -29,6 +30,7 @@ function reducer(state, action) {
export default function SidebarList({handleDrawerToggle}) {
const [itemMenu, dispatch] = useReducer(reducer, sidebarMenu);
const {user} = useUser();
// activate current page in menu
const router = useRouter();
@@ -40,14 +42,16 @@ export default function SidebarList({handleDrawerToggle}) {
<List>
{itemMenu.map((itemArr, index) => (
<Fragment key={index}>
{itemArr.map((item) => (
<SidebarListItem
item={item}
dispatch={dispatch}
key={item.key}
handleDrawerToggle={handleDrawerToggle}
/>
))}
{itemArr.map((item) =>
(item.userType === user.type_id || item.userType === 0) ? (
<SidebarListItem
item={item}
dispatch={dispatch}
key={item.key}
handleDrawerToggle={handleDrawerToggle}
/>
) : null
)}
<Divider/>
</Fragment>
))}