From 83c9e20aae281bcb798ca721a0b8e600b6ac9c59 Mon Sep 17 00:00:00 2001 From: Srinath Date: Thu, 29 Jan 2026 09:34:37 +0530 Subject: [PATCH] Added Emplyee Access missing names --- src/Pages/Offer/Offer/OfferListNew.jsx | 140 +++++++++++++++++++++---- 1 file changed, 120 insertions(+), 20 deletions(-) diff --git a/src/Pages/Offer/Offer/OfferListNew.jsx b/src/Pages/Offer/Offer/OfferListNew.jsx index 13b2871..509c513 100644 --- a/src/Pages/Offer/Offer/OfferListNew.jsx +++ b/src/Pages/Offer/Offer/OfferListNew.jsx @@ -27,7 +27,8 @@ import { } from '../../../Features/Offer/Offernew/Offernew.js'; import { Messages } from '../../../Components/Notifications/Messages.jsx'; -import { changeBreadCrumb } from '../../../Features/AppPage/CenterPage.js'; +import { changeBreadCrumb, getEmpAccess } from '../../../Features/AppPage/CenterPage.js'; +import { useAuth } from '../../../AuthContext.jsx'; const subDirectory = import.meta.env.ENV_BASE_URL; const OfferListNew = () => { @@ -39,6 +40,8 @@ const OfferListNew = () => { const AppId = getSession('AppId'); const CompId = getSession('CompId'); const BranchId = getSession('BranchId'); + const UserType = getSession('UserType'); + const UserId = getSession('UserId'); const [messageType, setMessageType] = useState(null); const [messageData, setMessageData] = useState(null); @@ -46,6 +49,10 @@ const OfferListNew = () => { const [page, setpage] = useState(1); const [sortedInfo, setSortedInfo] = useState({}); + const { SadminuserAccess } = useAuth(); + let SAAccessCommonMaster = SadminuserAccess?.find( + (e) => e?.MenuName === 'Product Based' + ); console.log(products, 'products'); const [allOffers, setAllOffers] = useState([]); @@ -54,6 +61,8 @@ const OfferListNew = () => { offer: null, newToDate: null, }); + const [empData, setEmpData] = useState(); + const [addnewAccess, setaddnewAccess] = useState(true); const items = [ { @@ -540,6 +549,37 @@ const OfferListNew = () => { // ]) }; + 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 === 'Product Based' + ); + setEmpData(datas?.[0]); + }; function ExtractDateFormate(dateString) { if (!dateString) return ''; @@ -683,73 +723,131 @@ const OfferListNew = () => { dataIndex: 'extend', key: 'extend', align: 'center', - render: (_, record) => - record?.ActiveStatus === 'A' ? ( + render: (_, record) => { + + const canUpdate = + UserType === 'Super Admin' || + UserType === 'Admin' || + (UserType === 'Super Admin User' && + SAAccessCommonMaster?.UpdateAccess === 'Y') || + (UserType === 'Employee' && empData?.UpdateAccess === 'Y'); + + const canEdit = + record?.ActiveStatus === 'A' && canUpdate; + + return record?.ActiveStatus === 'A' ? (
- setExtendModal({ open: true, offer: record, newToDate: null }) - } + className={canEdit ? 'extend-button' : 'extendisabled'} + onClick={() => { + if (!canEdit) return; + setExtendModal({ + open: true, + offer: record, + newToDate: null, + }); + }} style={{ height: '32px', width: '100px', - padding: '1 12px', + padding: '1px 12px', display: 'flex', alignItems: 'center', justifyContent: 'center', + cursor: canEdit ? 'pointer' : 'not-allowed', + opacity: canEdit ? 1 : 0.5, }} > Extend
) : (
Extend
- ), + ); + } }, + { title: 'Actions', dataIndex: 'actions', key: 'actions', - render: (_, record, index) => ( + render: (_, record, index) => { + + const canUpdate = + UserType === 'Super Admin' || + UserType === 'Admin' || + (UserType === 'Super Admin User' && SAAccessCommonMaster?.UpdateAccess === 'Y') || + (UserType === 'Employee' && empData?.UpdateAccess === 'Y'); + + const canDelete = + UserType === 'Super Admin' || + UserType === 'Admin' || + (UserType === 'Super Admin User' && SAAccessCommonMaster?.DeleteAccess === 'Y') || + (UserType === 'Employee' && empData?.DeleteAccess === 'Y'); + + return (
{ - (e.stopPropagation(), - setOpen((prev) => !prev), - setProducts(record)); + e.stopPropagation(); + setOpen((prev) => !prev); + setProducts(record); }} /> - {record.ActiveStatus == 'A' && ( + + {/* Edit */} + {record?.ActiveStatus === 'A' && ( { - (e.stopPropagation(), actionsFormatter(record, index)); + e.stopPropagation(); + if (!canUpdate) return; + actionsFormatter(record, index); }} /> )} - {record?.ActiveStatus == 'A' ? ( + {record?.ActiveStatus === 'A' ? ( { - (e.stopPropagation(), statusFormatter(record, index)); + e.stopPropagation(); + if (!canDelete) return; + statusFormatter(record, index); }} /> ) : ( { - (e.stopPropagation(), statusFormatter(record, index)); + e.stopPropagation(); + if (!canDelete) return; + statusFormatter(record, index); }} /> )}
- ), + ); }, + } + + ]; const handleNewOffer = () => { @@ -797,7 +895,9 @@ const OfferListNew = () => {

Product Offers

-