From 5e86a72700ccf5f71f38cc035300601abaff0e57 Mon Sep 17 00:00:00 2001 From: Swapnil Bendal <84583651+Swapnil155@users.noreply.github.com> Date: Fri, 17 Jan 2025 18:29:10 +0530 Subject: [PATCH] Filter navigation items based on user role in DashboardLayout component --- src/Layout/DefaultLayout.jsx | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Layout/DefaultLayout.jsx b/src/Layout/DefaultLayout.jsx index 843de6a..ad60b68 100644 --- a/src/Layout/DefaultLayout.jsx +++ b/src/Layout/DefaultLayout.jsx @@ -1,6 +1,5 @@ import React, { useContext, useEffect, useState } from "react"; import { CgProfile } from "react-icons/cg"; -import { useDispatch } from "react-redux"; import logoMiniDark from "../assets/favicon.png"; import logoMini from "../assets/logo-min.png"; import logoDark from "../assets/logo.png"; @@ -29,6 +28,7 @@ import { import Cookies from "js-cookie"; // Import the Cookies library import { GrManual } from "react-icons/gr"; import { HiOutlineChartSquareBar } from "react-icons/hi"; +import { HiOutlineBanknotes } from "react-icons/hi2"; import { LuContact } from "react-icons/lu"; import { MdNotificationsNone, MdOutlineAddChart } from "react-icons/md"; import { @@ -54,6 +54,7 @@ import { useNavigate, } from "react-router-dom"; import HeaderMain from "../Components/HeaderMain"; +import { isMaker } from "../Constants/Constants"; import GlobalStateContext from "../Contexts/GlobalStateContext"; import CreateRequest from "../Pages/Fawateer/CreateRequest"; import ApproveHistory from "../Pages/FawateerChecker/ApproveHistory/ApproveHistoryChecker"; @@ -65,7 +66,6 @@ import { nav } from "../Routes/Nav"; import { RouteLink } from "../Routes/Routes"; import { useProfileQuery } from "../Services/io.service"; import { useLogoutMutation } from "../Services/token.serivce"; -import { HiOutlineBanknotes } from "react-icons/hi2"; const DashboardLayout = ({ isOnline }) => { const navigate = useNavigate(); @@ -426,7 +426,17 @@ const DashboardLayout = ({ isOnline }) => { return ; } - const filteredNav = nav.map((item) => { + const _filteredNav = isMaker() + ? nav.filter( + (item) => + item.title !== "REVERSAL TRANSACTION" && + item.path !== "/bank-deposit-request" && + item.path !== "/reversal-fawateer-deposit" && + item.path !== "/account-deletion-request" + ) + : nav; + + const filteredNav = _filteredNav.map((item) => { if (item.submenu) { return { ...item, @@ -436,6 +446,9 @@ const DashboardLayout = ({ isOnline }) => { ), }; } + // if (item.title === "REVERSAL TRANSACTION" && item.type === "title") { + // } + return item; }); @@ -738,7 +751,7 @@ const DashboardLayout = ({ isOnline }) => { to={path} > {Icon && } -