Added Emplyee Access missing names
This commit is contained in:
parent
effafa34ee
commit
89d71c2617
|
|
@ -6,7 +6,7 @@ import { PlusOutlined } from '@ant-design/icons';
|
||||||
import { Messages } from '../../Components/Notifications/Messages';
|
import { Messages } from '../../Components/Notifications/Messages';
|
||||||
import { Tables } from '../../Components/Tables/Table';
|
import { Tables } from '../../Components/Tables/Table';
|
||||||
import { Search } from '../../Components/Forms/Search';
|
import { Search } from '../../Components/Forms/Search';
|
||||||
import { changeBreadCrumb } from '../../Features/AppPage/CenterPage.js';
|
import { changeBreadCrumb, getEmpAccess } from '../../Features/AppPage/CenterPage.js';
|
||||||
import { BsEye } from "react-icons/bs";
|
import { BsEye } from "react-icons/bs";
|
||||||
import Buttons from '../../Components/Forms/Buttons';
|
import Buttons from '../../Components/Forms/Buttons';
|
||||||
import { getSession } from '../../Services/Others';
|
import { getSession } from '../../Services/Others';
|
||||||
|
|
@ -14,6 +14,7 @@ import FormHeader from '../PageComponents/FormHeader.jsx';
|
||||||
import { getSalesReturn } from '../../Features/CancelReschedule/CancelApplicableProd.js';
|
import { getSalesReturn } from '../../Features/CancelReschedule/CancelApplicableProd.js';
|
||||||
import '../../Styles/OverAllStyle/OverAllStyle.scss';
|
import '../../Styles/OverAllStyle/OverAllStyle.scss';
|
||||||
import { DefaultModal } from '../../Components/Modal/DefaultModal.jsx';
|
import { DefaultModal } from '../../Components/Modal/DefaultModal.jsx';
|
||||||
|
import { useAuth } from '../../AuthContext.jsx';
|
||||||
|
|
||||||
const subDirectory = import.meta.env.ENV_BASE_URL;
|
const subDirectory = import.meta.env.ENV_BASE_URL;
|
||||||
const items = [
|
const items = [
|
||||||
|
|
@ -33,16 +34,24 @@ const items = [
|
||||||
];
|
];
|
||||||
|
|
||||||
const SalesBillProductReturnList = () => {
|
const SalesBillProductReturnList = () => {
|
||||||
|
const { SadminuserAccess } = useAuth();
|
||||||
|
const SAAccessCommonMaster = SadminuserAccess?.find(
|
||||||
|
(e) => e?.MenuName === 'Sales Product Return'
|
||||||
|
);
|
||||||
const [page, setpage] = useState(1);
|
const [page, setpage] = useState(1);
|
||||||
const CompId = getSession('CompId');
|
const CompId = getSession('CompId');
|
||||||
const BranchId = getSession('BranchId');
|
const BranchId = getSession('BranchId');
|
||||||
const AppId = getSession('AppId');
|
const AppId = getSession('AppId');
|
||||||
|
const UserId = getSession('UserId');
|
||||||
|
const UserType = getSession('UserType');
|
||||||
const navigateTo = useNavigate();
|
const navigateTo = useNavigate();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const [tabledata, setTabledata] = useState();
|
const [tabledata, setTabledata] = useState();
|
||||||
const [message, setMessage] = useState({ type: null, data: null });
|
const [message, setMessage] = useState({ type: null, data: null });
|
||||||
const [searchedText, setSearchedText] = useState('');
|
const [searchedText, setSearchedText] = useState('');
|
||||||
const [sortedInfo, setSortedInfo] = useState({});
|
const [sortedInfo, setSortedInfo] = useState({});
|
||||||
|
const [empData, setEmpData] = useState();
|
||||||
|
const [addnewAccess, setaddnewAccess] = useState(true);
|
||||||
const [productDetailsModel, setProductDetailsModel] = useState({
|
const [productDetailsModel, setProductDetailsModel] = useState({
|
||||||
model: false,
|
model: false,
|
||||||
data: []
|
data: []
|
||||||
|
|
@ -98,6 +107,38 @@ const SalesBillProductReturnList = () => {
|
||||||
setMessage({ type: null, data: null })
|
setMessage({ type: null, data: null })
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
||||||
|
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 Product Return'
|
||||||
|
);
|
||||||
|
setEmpData(datas?.[0]);
|
||||||
|
};
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
title: 'Sl.No',
|
title: 'Sl.No',
|
||||||
|
|
@ -170,6 +211,7 @@ const SalesBillProductReturnList = () => {
|
||||||
buttonText={'Add New'}
|
buttonText={'Add New'}
|
||||||
handleSubmit={() => handelAddButton()}
|
handleSubmit={() => handelAddButton()}
|
||||||
color="901D77"
|
color="901D77"
|
||||||
|
disabled={addnewAccess}
|
||||||
icon={<PlusOutlined />}
|
icon={<PlusOutlined />}
|
||||||
>
|
>
|
||||||
OPEN
|
OPEN
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue