Added Emplyee Access missing names
This commit is contained in:
parent
0530e749a2
commit
8959025a31
|
|
@ -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 = () => {
|
|||
<Buttons
|
||||
buttonText={'Add New '}
|
||||
handleSubmit={handleAddNew}
|
||||
disabled={addnewAccess}
|
||||
icon={<PlusOutlined />}
|
||||
color="901D77"
|
||||
/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue