Added Emplyee Access missing names
This commit is contained in:
parent
377b9c0d87
commit
b1c7d45aed
|
|
@ -1,7 +1,7 @@
|
||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch } from "react-redux";
|
||||||
import { getSession } from "../../Services/Others";
|
import { getSession } from "../../Services/Others";
|
||||||
import { changeBreadCrumb } from "../../Features/AppPage/CenterPage";
|
import { changeBreadCrumb, getEmpAccess } from "../../Features/AppPage/CenterPage";
|
||||||
import { Messages } from "../../Components/Notifications/Messages";
|
import { Messages } from "../../Components/Notifications/Messages";
|
||||||
import { Tables } from "../../Components/Tables/Table";
|
import { Tables } from "../../Components/Tables/Table";
|
||||||
import FormHeader from "../PageComponents/FormHeader";
|
import FormHeader from "../PageComponents/FormHeader";
|
||||||
|
|
@ -19,6 +19,7 @@ import { deleteAutomatedReorder, getAutomatedReorderList } from "../../Features/
|
||||||
import { DefaultModal } from "../../Components/Modal/DefaultModal";
|
import { DefaultModal } from "../../Components/Modal/DefaultModal";
|
||||||
import { FaRegEye } from "react-icons/fa";
|
import { FaRegEye } from "react-icons/fa";
|
||||||
import { render } from "react-dom";
|
import { render } from "react-dom";
|
||||||
|
import { useAuth } from "../../AuthContext";
|
||||||
|
|
||||||
const subDirectory = import.meta.env.BASE_URL;
|
const subDirectory = import.meta.env.BASE_URL;
|
||||||
|
|
||||||
|
|
@ -40,11 +41,18 @@ const AutomatedReorderList = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const state = location?.state;
|
const state = location?.state;
|
||||||
|
const { SadminuserAccess } = useAuth();
|
||||||
|
let SAAccessCommonMaster = SadminuserAccess?.find(
|
||||||
|
(e) => e?.MenuName === 'Product Receipt'
|
||||||
|
);
|
||||||
|
|
||||||
const AppId = getSession('AppId');
|
const AppId = getSession('AppId');
|
||||||
const CompId = getSession('CompId');
|
const CompId = getSession('CompId');
|
||||||
const BranchId = getSession('BranchId');
|
const BranchId = getSession('BranchId');
|
||||||
const UserId = getSession('UserId');
|
const UserId = getSession('UserId');
|
||||||
|
const UserType = getSession('UserType');
|
||||||
|
const [empData, setEmpData] = useState();
|
||||||
|
const [addnewAccess, setaddnewAccess] = useState(true);
|
||||||
|
|
||||||
const [messageType, setMessageType] = useState(null);
|
const [messageType, setMessageType] = useState(null);
|
||||||
const [messageData, setMessageData] = useState(null);
|
const [messageData, setMessageData] = useState(null);
|
||||||
|
|
@ -176,6 +184,40 @@ const AutomatedReorderList = () => {
|
||||||
}
|
}
|
||||||
}, [AppId, CompId, BranchId]);
|
}, [AppId, CompId, BranchId]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (UserType === 'Employee') {
|
||||||
|
fetchApi();
|
||||||
|
}
|
||||||
|
}, [UserType]);
|
||||||
|
|
||||||
|
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]);
|
||||||
|
|
||||||
|
const fetchApi = 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 === 'Automated Reorder'
|
||||||
|
);
|
||||||
|
setEmpData(datas?.[0]);
|
||||||
|
};
|
||||||
|
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await dispatch(getAutomatedReorderList({ AppId, CompId, BranchId }))?.unwrap();
|
const res = await dispatch(getAutomatedReorderList({ AppId, CompId, BranchId }))?.unwrap();
|
||||||
|
|
@ -251,6 +293,7 @@ const AutomatedReorderList = () => {
|
||||||
<Buttons
|
<Buttons
|
||||||
buttonText={'Add New'}
|
buttonText={'Add New'}
|
||||||
handleSubmit={handleAdd}
|
handleSubmit={handleAdd}
|
||||||
|
disabled={addnewAccess}
|
||||||
color="901D77"
|
color="901D77"
|
||||||
icon={<PlusOutlined />}
|
icon={<PlusOutlined />}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue