From 8959025a31b7b6df26065f884839207551605cc8 Mon Sep 17 00:00:00 2001 From: Srinath Date: Thu, 29 Jan 2026 09:32:46 +0530 Subject: [PATCH] Added Emplyee Access missing names --- .../ExchangeReturnMapList.jsx | 48 +++++++++++++++++-- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/src/Pages/ExchangeReturnMap/ExchangeReturnMapList.jsx b/src/Pages/ExchangeReturnMap/ExchangeReturnMapList.jsx index 921e715..14be4f8 100644 --- a/src/Pages/ExchangeReturnMap/ExchangeReturnMapList.jsx +++ b/src/Pages/ExchangeReturnMap/ExchangeReturnMapList.jsx @@ -4,7 +4,7 @@ import Search from '../../Components/Forms/Search'; import { Tables } from '../../Components/Tables/Table'; import FormHeader from '../PageComponents/FormHeader'; import { useNavigate } from 'react-router-dom'; -import { changeBreadCrumb } from '../../Features/AppPage/CenterPage'; +import { changeBreadCrumb, getEmpAccess } from '../../Features/AppPage/CenterPage'; import { DeleteFilled, EditFilled, @@ -26,7 +26,7 @@ import { import { Space, Table, message, Modal, Alert } from 'antd'; import { DefaultModal } from '../../Components/Modal/DefaultModal'; import { IoEye } from 'react-icons/io5'; - +import { useAuth } from '../../AuthContext'; const subDirectory = import.meta.env.BASE_URL; const items = [ { @@ -40,6 +40,11 @@ const items = [ }, ]; const ExchangeReturnMapList = () => { + + const { SadminuserAccess } = useAuth(); + const SAAccessCommonMaster = SadminuserAccess?.find( + (e) => e?.MenuName === 'Rules Mapping' + ); const dispatch = useDispatch(); const CompId = getSession('CompId'); const BranchId = getSession('BranchId'); @@ -53,7 +58,7 @@ const ExchangeReturnMapList = () => { const [messageData, setMessageData] = useState(null); // Add missing variables for access control - const [SAAccessCommonMaster, setSAAccessCommonMaster] = useState({}); + const [addnewAccess, setaddnewAccess] = useState(true); const [empData, setEmpData] = useState({}); const [sortedInfo, setSortedInfo] = useState({}); @@ -132,6 +137,38 @@ const ExchangeReturnMapList = () => { // } // }; + useEffect(() => { + let hasAccess = false; + if (UserType === 'Admin' || UserType === 'Super Admin') { + hasAccess = true; + } else if (UserType === 'Employee') { + hasAccess = empData?.AddAccess === 'Y'; + } else if (UserType === 'Super Admin User') { + hasAccess = SAAccessCommonMaster?.AddAccess === 'Y'; + } + + setaddnewAccess(!hasAccess); + }, [empData, SAAccessCommonMaster, UserType]); + useEffect(() => { + if (UserType === "Employee") { + fetchApiEmpAccess() + } + }, [UserType]) + const fetchApiEmpAccess = async () => { + let data = { + CompId: CompId, + BranchId: BranchId, + AppId: AppId, + EmpId: UserId, + }; + let response = await dispatch(getEmpAccess(data)).unwrap(); + let datas = response?.data?.data?.[0]?.EmpAccessDetails?.filter( + (item) => item.ConfigName === 'Rules Mapping' + ); + setEmpData(datas?.[0]); + }; + + const statusDeactive = async (data) => { let deleteData = { PolicyId: data.PolicyId, @@ -270,7 +307,7 @@ const ExchangeReturnMapList = () => { (UserType === 'Super Admin User' && SAAccessCommonMaster?.UpdateAccess === 'Y') || (UserType === 'Employee' && - empData?.UpdateAccess === 'Y') || + addnewAccess) || UserType === 'Admin' ? actionsFormatter(record, index) : null @@ -301,7 +338,7 @@ const ExchangeReturnMapList = () => { (UserType === 'Super Admin User' && SAAccessCommonMaster?.DeleteAccess === 'Y') || (UserType === 'Employee' && - empData?.DeleteAccess === 'Y') || + addnewAccess) || UserType === 'Admin' ? statusDeactive(record) : null @@ -441,6 +478,7 @@ const ExchangeReturnMapList = () => { } color="901D77" />