Added Emplyee Access missing names
This commit is contained in:
parent
43adb378b8
commit
7885feb3ec
|
|
@ -1,7 +1,7 @@
|
||||||
import React, { useState, useCallback, useEffect } from 'react';
|
import React, { useState, useCallback, useEffect } from 'react';
|
||||||
import { Messages } from '../../../Components/Notifications/Messages';
|
import { Messages } from '../../../Components/Notifications/Messages';
|
||||||
import { useNavigate, useLocation } from 'react-router-dom';
|
import { useNavigate, useLocation } from 'react-router-dom';
|
||||||
import { changeBreadCrumb } from '../../../Features/AppPage/CenterPage';
|
import { changeBreadCrumb, getEmpAccess } from '../../../Features/AppPage/CenterPage';
|
||||||
import FormHeader from '../../PageComponents/FormHeader';
|
import FormHeader from '../../PageComponents/FormHeader';
|
||||||
import Buttons from '../../../Components/Forms/Buttons';
|
import Buttons from '../../../Components/Forms/Buttons';
|
||||||
import Search from '../../../Components/Forms/Search';
|
import Search from '../../../Components/Forms/Search';
|
||||||
|
|
@ -21,6 +21,7 @@ import {
|
||||||
} from '../../../Features/StoreKitchen/StoreRecipe';
|
} from '../../../Features/StoreKitchen/StoreRecipe';
|
||||||
import { getSession } from '../../../Services/Others';
|
import { getSession } from '../../../Services/Others';
|
||||||
import { DefaultModal } from '../../../Components/Modal/DefaultModal';
|
import { DefaultModal } from '../../../Components/Modal/DefaultModal';
|
||||||
|
import { useAuth } from '../../../AuthContext';
|
||||||
|
|
||||||
const StoreRecipelist = () => {
|
const StoreRecipelist = () => {
|
||||||
const subDirectory = import.meta.env.ENV_BASE_URL;
|
const subDirectory = import.meta.env.ENV_BASE_URL;
|
||||||
|
|
@ -34,6 +35,8 @@ const StoreRecipelist = () => {
|
||||||
const AppId = getSession('AppId');
|
const AppId = getSession('AppId');
|
||||||
const UserId = getSession('UserId');
|
const UserId = getSession('UserId');
|
||||||
const UserType = getSession('UserType');
|
const UserType = getSession('UserType');
|
||||||
|
const { SadminuserAccess } = useAuth();
|
||||||
|
let SAAccessCommonMaster = SadminuserAccess?.find((e) => e?.MenuName === "Bill Of Material");
|
||||||
|
|
||||||
const [messageType, setMessageType] = useState(null);
|
const [messageType, setMessageType] = useState(null);
|
||||||
const [messageData, setMessageData] = useState(null);
|
const [messageData, setMessageData] = useState(null);
|
||||||
|
|
@ -44,6 +47,8 @@ const StoreRecipelist = () => {
|
||||||
const [sortedInfo, setSortedInfo] = useState({});
|
const [sortedInfo, setSortedInfo] = useState({});
|
||||||
const [CreatedProductdata, setCreatedProductdata] = useState();
|
const [CreatedProductdata, setCreatedProductdata] = useState();
|
||||||
const [CreatedProdModal, setCreatedProdModal] = useState();
|
const [CreatedProdModal, setCreatedProdModal] = useState();
|
||||||
|
const [empData, setEmpData] = useState();
|
||||||
|
const [addnewAccess, setaddnewAccess] = useState(true);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dispatch(changeBreadCrumb({ items: items }));
|
dispatch(changeBreadCrumb({ items: items }));
|
||||||
|
|
@ -58,6 +63,41 @@ const StoreRecipelist = () => {
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
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 === 'Bill Of Material')
|
||||||
|
setEmpData(datas?.[0])
|
||||||
|
|
||||||
|
}
|
||||||
const onComplete = useCallback(() => {
|
const onComplete = useCallback(() => {
|
||||||
setMessageData(null);
|
setMessageData(null);
|
||||||
setMessageType(null);
|
setMessageType(null);
|
||||||
|
|
@ -315,7 +355,7 @@ const StoreRecipelist = () => {
|
||||||
<div className="productMaster-input">
|
<div className="productMaster-input">
|
||||||
<Buttons
|
<Buttons
|
||||||
buttonText={'Add New'}
|
buttonText={'Add New'}
|
||||||
// disabled={addnewAccess}
|
disabled={addnewAccess}
|
||||||
handleSubmit={() => handelAddButton()}
|
handleSubmit={() => handelAddButton()}
|
||||||
color="901D77"
|
color="901D77"
|
||||||
icon={<PlusOutlined />}
|
icon={<PlusOutlined />}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue