From effafa34ee6a46ed7ef21af80fadabf8b3316db9 Mon Sep 17 00:00:00 2001 From: Srinath Date: Wed, 28 Jan 2026 19:34:00 +0530 Subject: [PATCH] Added Emplyee Access missing names --- .../SalesRemoval/SalesBillCancelList.jsx | 46 ++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/src/Pages/SalesRemoval/SalesBillCancelList.jsx b/src/Pages/SalesRemoval/SalesBillCancelList.jsx index 2c91956..0490639 100644 --- a/src/Pages/SalesRemoval/SalesBillCancelList.jsx +++ b/src/Pages/SalesRemoval/SalesBillCancelList.jsx @@ -26,11 +26,12 @@ import { import { DefaultModal } from '../../Components/Modal/DefaultModal.jsx'; import { Form, Table, Input } from 'antd'; import { TiDelete } from 'react-icons/ti'; -import { changeBreadCrumb } from '../../Features/AppPage/CenterPage.js'; +import { changeBreadCrumb, getEmpAccess } from '../../Features/AppPage/CenterPage.js'; import { EditFilled, StopOutlined } from '@ant-design/icons'; import { ArrowRightOutlined } from '@ant-design/icons'; import { DropDowns } from '../../Components/Forms/DropDown.jsx'; import { CgCloseR } from 'react-icons/cg'; +import { useAuth } from '../../AuthContext.jsx'; const SalesRemovallist = () => { const dispatch = useDispatch(); @@ -38,8 +39,13 @@ const SalesRemovallist = () => { const BranchId = getSession('BranchId'); const AppId = getSession('AppId'); const UserId = getSession('UserId'); + const UserType = getSession('UserType'); const formRef = useRef(null); const { RangePicker } = DatePicker; + const { SadminuserAccess } = useAuth(); + const SAAccessCommonMaster = SadminuserAccess?.find( + (e) => e?.MenuName === 'Sales Entry Cancel' + ); const [messageType, setMessageType] = useState(null); const [messageData, setMessageData] = useState(null); @@ -64,6 +70,8 @@ const SalesRemovallist = () => { const [IdentifyDetails, setIdentifyDetails] = useState([]); const [Identifiersnumber, setIdentifiersnumber] = useState([]); const [Qty, setQty] = useState(); + const [empData, setEmpData] = useState(); + const [addnewAccess, setaddnewAccess] = useState(true); const subDirectory = import.meta.env.ENV_BASE_URL; @@ -79,6 +87,8 @@ const SalesRemovallist = () => { ]; + + const onComplete = useCallback(() => { setMessageData(null); setMessageType(null); @@ -107,6 +117,39 @@ const SalesRemovallist = () => { dispatch(changeBreadCrumb({ items: items })); Tabledatas(); }, []); + + 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") { + fetchApi() + } + }, [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 === 'Sales Entry Cancel' + ); + setEmpData(datas?.[0]); + }; + function safeRound(amountStr) { if (amountStr == null) return '0.00'; const cleaned = String(amountStr).replace(/[^0-9.-]+/g, ''); @@ -1252,6 +1295,7 @@ const SalesRemovallist = () => { } handleSubmit={handleSubmit} />