Added Emplyee Access missing names
This commit is contained in:
parent
381fbbf2ff
commit
f8297e9705
|
|
@ -35,7 +35,7 @@ import { InputField } from '../../Components/Forms/InputField.jsx';
|
||||||
import Buttons from '../../Components/Forms/Buttons.jsx';
|
import Buttons from '../../Components/Forms/Buttons.jsx';
|
||||||
import { Messages } from '../../Components/Notifications/Messages.jsx';
|
import { Messages } from '../../Components/Notifications/Messages.jsx';
|
||||||
import { DeleteFilled } from '@ant-design/icons';
|
import { DeleteFilled } from '@ant-design/icons';
|
||||||
import { changeBreadCrumb } from '../../Features/AppPage/CenterPage.js';
|
import { changeBreadCrumb, getEmpAccess } from '../../Features/AppPage/CenterPage.js';
|
||||||
import FormHeader from '../PageComponents/FormHeader.jsx';
|
import FormHeader from '../PageComponents/FormHeader.jsx';
|
||||||
import { DefaultModal } from '../../Components/Modal/DefaultModal.jsx';
|
import { DefaultModal } from '../../Components/Modal/DefaultModal.jsx';
|
||||||
import { getSession, validateSafeInput } from '../../Services/Others.js';
|
import { getSession, validateSafeInput } from '../../Services/Others.js';
|
||||||
|
|
@ -65,6 +65,7 @@ import {
|
||||||
import { FiUploadCloud } from 'react-icons/fi';
|
import { FiUploadCloud } from 'react-icons/fi';
|
||||||
import OpeningStockExcel from './OpeningStockExcel.jsx';
|
import OpeningStockExcel from './OpeningStockExcel.jsx';
|
||||||
import { sendupiotp } from '../../Features/UpiDetails/UpiDetails.js';
|
import { sendupiotp } from '../../Features/UpiDetails/UpiDetails.js';
|
||||||
|
import { useAuth } from '../../AuthContext.jsx';
|
||||||
|
|
||||||
const subDirectory = import.meta.env.BASE_URL;
|
const subDirectory = import.meta.env.BASE_URL;
|
||||||
const EditableContext = React.createContext(null);
|
const EditableContext = React.createContext(null);
|
||||||
|
|
@ -160,6 +161,10 @@ const OpeningStockList = () => {
|
||||||
const productAddInfoRef = useRef(null);
|
const productAddInfoRef = useRef(null);
|
||||||
const navigateTo = useNavigate();
|
const navigateTo = useNavigate();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
const { SadminuserAccess } = useAuth();
|
||||||
|
let SAAccessCommonMaster = SadminuserAccess?.find(
|
||||||
|
(e) => e?.MenuName === 'Opening Stock'
|
||||||
|
);
|
||||||
|
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
|
|
@ -171,7 +176,10 @@ const OpeningStockList = () => {
|
||||||
const BranchId = getSession('BranchId');
|
const BranchId = getSession('BranchId');
|
||||||
const AppId = getSession('AppId');
|
const AppId = getSession('AppId');
|
||||||
const UserId = getSession('UserId');
|
const UserId = getSession('UserId');
|
||||||
|
const UserType = getSession('UserType');
|
||||||
const MobileNo = getSession('MobileNo');
|
const MobileNo = getSession('MobileNo');
|
||||||
|
const [empData, setEmpData] = useState();
|
||||||
|
const [addnewAccess, setaddnewAccess] = useState(true);
|
||||||
|
|
||||||
const [openExcel, setOpenExcel] = useState(false);
|
const [openExcel, setOpenExcel] = useState(false);
|
||||||
const [applicationRestrictedFields, setApplicationRestrictedFields] =
|
const [applicationRestrictedFields, setApplicationRestrictedFields] =
|
||||||
|
|
@ -207,6 +215,40 @@ const OpeningStockList = () => {
|
||||||
return () => clearTimeout(timer);
|
return () => clearTimeout(timer);
|
||||||
}
|
}
|
||||||
}, [timeLeft]);
|
}, [timeLeft]);
|
||||||
|
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 === 'Opening Stock'
|
||||||
|
);
|
||||||
|
setEmpData(datas?.[0]);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
console.log(otpAccessMap, 'otpAccessMap');
|
console.log(otpAccessMap, 'otpAccessMap');
|
||||||
const [Delete, setDelete] = useState(false);
|
const [Delete, setDelete] = useState(false);
|
||||||
|
|
@ -1209,6 +1251,7 @@ const OpeningStockList = () => {
|
||||||
<Buttons
|
<Buttons
|
||||||
buttonText={'Add New'}
|
buttonText={'Add New'}
|
||||||
handleSubmit={() => handelAddButton()}
|
handleSubmit={() => handelAddButton()}
|
||||||
|
disabled={addnewAccess}
|
||||||
color="901D77"
|
color="901D77"
|
||||||
icon={<PlusOutlined />}
|
icon={<PlusOutlined />}
|
||||||
/>
|
/>
|
||||||
|
|
@ -1218,7 +1261,7 @@ const OpeningStockList = () => {
|
||||||
buttonText="Upload Excel"
|
buttonText="Upload Excel"
|
||||||
className="tertiary_Button"
|
className="tertiary_Button"
|
||||||
handleSubmit={openModal}
|
handleSubmit={openModal}
|
||||||
disabled={false}
|
disabled={addnewAccess}
|
||||||
icon={<FiUploadCloud size={18} />}
|
icon={<FiUploadCloud size={18} />}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue