Added Emplyee Access missing names
This commit is contained in:
parent
f8297e9705
commit
8f6c653f91
|
|
@ -11,7 +11,7 @@ import {
|
|||
import Buttons from '../../Components/Forms/Buttons';
|
||||
import './StockAdjustment.scss';
|
||||
import { DropDowns } from '../../Components/Forms/DropDown';
|
||||
import { changeBreadCrumb } from '../../Features/AppPage/CenterPage';
|
||||
import { changeBreadCrumb, getEmpAccess } from '../../Features/AppPage/CenterPage';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { getSession } from '../../Services/Others';
|
||||
import { getAllprodIName } from '../../Features/ProductPage/ProductPage';
|
||||
|
|
@ -25,17 +25,26 @@ import FormHeader from '../PageComponents/FormHeader';
|
|||
import { useNavigate } from 'react-router-dom';
|
||||
import { DefaultModal } from '../../Components/Modal/DefaultModal';
|
||||
import { IoBagRemove } from 'react-icons/io5';
|
||||
import { useAuth } from '../../AuthContext';
|
||||
|
||||
const subDirectory = import.meta.env.BASE_URL;
|
||||
const StockAdjustment = () => {
|
||||
|
||||
const { SadminuserAccess } = useAuth();
|
||||
let SAAccessCommonMaster = SadminuserAccess?.find(
|
||||
(e) => e?.MenuName === 'Stock Adjustment'
|
||||
);
|
||||
const dispatch = useDispatch();
|
||||
const navigate = useNavigate();
|
||||
const CompId = getSession('CompId');
|
||||
const BranchId = getSession('BranchId');
|
||||
const AppId = getSession('AppId');
|
||||
const UserId = getSession('UserId');
|
||||
const UserType = getSession('UserType');
|
||||
const [productsData, setProductsData] = useState([]);
|
||||
const [stockData, setStockData] = useState([]);
|
||||
const [empData, setEmpData] = useState();
|
||||
const [addnewAccess, setaddnewAccess] = useState(true);
|
||||
|
||||
const uniqueData = useMemo(() => {
|
||||
return stockData.reduce((acc, current) => {
|
||||
|
|
@ -164,6 +173,42 @@ const StockAdjustment = () => {
|
|||
// link: null,
|
||||
// },
|
||||
];
|
||||
|
||||
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 === 'Stock Adjustment'
|
||||
);
|
||||
setEmpData(datas?.[0]);
|
||||
};
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(changeBreadCrumb({ items: items }));
|
||||
getAllProduct();
|
||||
|
|
@ -318,6 +363,7 @@ const StockAdjustment = () => {
|
|||
<Buttons
|
||||
buttonText="Search"
|
||||
handleSubmit={handleTriggerClick}
|
||||
disabled = {addnewAccess}
|
||||
style={{ marginLeft: 8 }}
|
||||
icon={<FiSearch size={16} />}
|
||||
/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue