Added Emplyee Access missing names
This commit is contained in:
parent
c8bf1d22f8
commit
ea17ccf76b
|
|
@ -20,11 +20,12 @@ import {
|
||||||
ApplicationPreferences,
|
ApplicationPreferences,
|
||||||
getBranchDetail,
|
getBranchDetail,
|
||||||
} from '../../Features/BrachLogin/BranchLogin';
|
} from '../../Features/BrachLogin/BranchLogin';
|
||||||
import { changeBreadCrumb } from '../../Features/AppPage/CenterPage';
|
import { changeBreadCrumb, getEmpAccess } from '../../Features/AppPage/CenterPage';
|
||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import PublicQrCodeShare from './PublicQrCodeShare/PublicQrCodeShare';
|
import PublicQrCodeShare from './PublicQrCodeShare/PublicQrCodeShare';
|
||||||
import { FeatureAddon } from '../../Features/BookingScreen/BookingData/BookingData';
|
import { FeatureAddon } from '../../Features/BookingScreen/BookingData/BookingData';
|
||||||
import { getPaymentOptionsData } from '../../Features/Payment/Paymentoptions/Paymentoptions';
|
import { getPaymentOptionsData } from '../../Features/Payment/Paymentoptions/Paymentoptions';
|
||||||
|
import { useAuth } from '../../AuthContext';
|
||||||
|
|
||||||
const subDirectory = import.meta.env.ENV_MAIN_BASE_URL;
|
const subDirectory = import.meta.env.ENV_MAIN_BASE_URL;
|
||||||
const items = [
|
const items = [
|
||||||
|
|
@ -56,6 +57,8 @@ const PublicQrCode = () => {
|
||||||
const [Tabledata, setTabledata] = useState([]);
|
const [Tabledata, setTabledata] = useState([]);
|
||||||
const [CheckTabledata, setCheckTabledata] = useState([]);
|
const [CheckTabledata, setCheckTabledata] = useState([]);
|
||||||
const [qrCodeUrl, setQrCodeUrl] = useState('');
|
const [qrCodeUrl, setQrCodeUrl] = useState('');
|
||||||
|
const [empData, setEmpData] = useState();
|
||||||
|
const [addnewAccess, setaddnewAccess] = useState(true);
|
||||||
const [selectedConfig, setSelectedConfig] = useState({
|
const [selectedConfig, setSelectedConfig] = useState({
|
||||||
id: '',
|
id: '',
|
||||||
name: 'Both',
|
name: 'Both',
|
||||||
|
|
@ -77,6 +80,11 @@ const PublicQrCode = () => {
|
||||||
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 { SadminuserAccess } = useAuth();
|
||||||
|
const SAAccessCommonMaster = SadminuserAccess?.find(
|
||||||
|
(e) => e?.MenuName === 'SelfBooking QR Code'
|
||||||
|
);
|
||||||
const allowed = ['TakeAway', CheckTabledata?.length > 0 ? 'Dine In' : ''];
|
const allowed = ['TakeAway', CheckTabledata?.length > 0 ? 'Dine In' : ''];
|
||||||
const bookingTypePreference = appPreferences?.find(
|
const bookingTypePreference = appPreferences?.find(
|
||||||
(preference) => preference?.PreferredCatName === 'Booking Type'
|
(preference) => preference?.PreferredCatName === 'Booking Type'
|
||||||
|
|
@ -209,6 +217,38 @@ const PublicQrCode = () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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") {
|
||||||
|
fetchApiEmpAccess()
|
||||||
|
}
|
||||||
|
}, [UserType])
|
||||||
|
const fetchApiEmpAccess = 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 === 'SelfBooking QR Code'
|
||||||
|
);
|
||||||
|
setEmpData(datas?.[0]);
|
||||||
|
};
|
||||||
|
|
||||||
const fetchApi = async () => {
|
const fetchApi = async () => {
|
||||||
let response = await dispatch(getConfiguration({ Type: 'SA' })).unwrap();
|
let response = await dispatch(getConfiguration({ Type: 'SA' })).unwrap();
|
||||||
if (response?.data?.statusCode === 1) {
|
if (response?.data?.statusCode === 1) {
|
||||||
|
|
@ -700,7 +740,7 @@ const PublicQrCode = () => {
|
||||||
className="tertiary_Button"
|
className="tertiary_Button"
|
||||||
color="901D77"
|
color="901D77"
|
||||||
handleSubmit={HandleSubmit}
|
handleSubmit={HandleSubmit}
|
||||||
// disabled={addnewAccess}
|
disabled={addnewAccess}
|
||||||
icon={<PlusOutlined />}
|
icon={<PlusOutlined />}
|
||||||
>
|
>
|
||||||
GENERATE
|
GENERATE
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue