diff --git a/src/App.jsx b/src/App.jsx
index 69ae4f7..b4d9eee 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -2,7 +2,6 @@ import { useEffect, lazy, Suspense } from 'react';
import { Routes, Route } from 'react-router-dom';
import { useSelector } from 'react-redux';
import ProtectedRoutes from './ProtectedRoutes';
-import SelfBooking from './Pages/SelfBooking/SelfBooking.jsx';
import { isMobile, isIOS } from 'react-device-detect';
import { routesConfig } from './routesConfig';
import { GlobalItemCard } from './Features/BookingScreen/BookingData/BookingData.js';
@@ -15,19 +14,30 @@ const KisokSelBooking = lazy(
const IndividualBooking = lazy(
() => import('./Pages/SelfBooking/IndividualBooking')
);
+
+const CustomerMenuPage = lazy(
+ () => import('./Pages/Reports/MenuQRCode/CustomerMenuPage.jsx')
+);
+const WeightScaleApp = lazy(
+ () => import('./Pages/BookingScreen/WeightscaleApp.jsx')
+);
+const SelfBooking = lazy(() => import('./Pages/SelfBooking/SelfBooking.jsx'));
+
+import useSessionManager from './useSessionManager.js';
+import useSubscriptionManager from './useSubscriptionManager.js';
+const ExtendSubscriptionModal = lazy(
+ () => import('./Pages/ExtentedModal/ExtendSubscriptionModal.jsx')
+);
+
const commonSubDir = import.meta.env.ENV_COMMON_BASE_URL;
const subDirectory = import.meta.env.ENV_BASE_URL;
import '../ownLib/my-ui-lib.css';
-import CustomerMenuPage from './Pages/Reports/MenuQRCode/CustomerMenuPage.jsx';
-import WeightScaleApp from './Pages/BookingScreen/WeightscaleApp.jsx';
-import useSubscriptionManager from './useSubscriptionManager.js';
-import useSessionManager from './useSessionManager.js';
-import ExtendSubscriptionModal from './Pages/ExtentedModal/ExtendSubscriptionModal.jsx';
const AppRoutes = () => {
const ItemCard = useSelector(GlobalItemCard);
const { sessionData, logout } = useSessionManager(ItemCard);
- const { remainingDays, handleCancel, freeExtend, extendModel,setExtendModel } = useSubscriptionManager(sessionData, logout);
+ const { remainingDays, handleCancel, handlePay, freeExtend, extendModel } =
+ useSubscriptionManager(sessionData, logout);
useEffect(() => {
const handlePopState = () => {
@@ -64,12 +74,12 @@ const AppRoutes = () => {
// return () => clearInterval(timer);
// }, []);
-
if (extendModel) {
return (
);
}
diff --git a/src/AuthContext.jsx b/src/AuthContext.jsx
index 8639e99..c2c5445 100644
--- a/src/AuthContext.jsx
+++ b/src/AuthContext.jsx
@@ -5,13 +5,9 @@ import { getSession } from './Services/Others';
import {
getEmpAccesData,
getSAdminUserAccesData,
- PricingAppPricingName,
} from './Features/BrachLogin/BranchLogin.js';
-import { changePricingAppPricingName } from './Features/ThemeChange/ThemeChange.js';
-import {
- FeatureAddon,
- GlobalFeatAddOnData,
-} from './Features/BookingScreen/BookingData/BookingData.js';
+import { PricingAppPricingNameData } from './Features/ThemeChange/ThemeChange.js';
+import { GlobalFeatAddOnData } from './Features/BookingScreen/BookingData/BookingData.js';
import { useSelector } from 'react-redux';
export const AuthContext = createContext();
@@ -50,16 +46,24 @@ export const AuthProvider = ({ children }) => {
const getPricingName = async () => {
if (!AppId || !UserId) return;
- const data = {
- appId: AppId,
- userId: UserId,
- };
+ let data;
+ if (UserType === 'Super Admin' || UserType === 'Super Admin User') {
+ data = {
+ appId: AppId,
+ compId: CompId,
+ branchId: BranchId,
+ };
+ } else {
+ data = {
+ appId: AppId,
+ userId: UserId,
+ };
+ }
try {
- const response = await dispatch(PricingAppPricingName(data)).unwrap();
+ const response = await dispatch(PricingAppPricingNameData(data)).unwrap();
const responseData = response?.data;
if (responseData?.statusCode !== 1) return setAdvance(false);
const pricingData = responseData?.data;
- await dispatch(changePricingAppPricingName(pricingData));
const hasAdvance = pricingData.some(
(item) => item.PricingName === 'Premium'
);
diff --git a/src/Pages/BookingScreen/BookingPage.jsx b/src/Pages/BookingScreen/BookingPage.jsx
index 9dd1004..0e6ef32 100644
--- a/src/Pages/BookingScreen/BookingPage.jsx
+++ b/src/Pages/BookingScreen/BookingPage.jsx
@@ -1,5 +1,6 @@
-import { useEffect, useState, lazy, Suspense } from 'react';
-import { useSelector, useDispatch } from 'react-redux';
+import { useEffect, useRef, lazy, Suspense, memo } from 'react';
+import { useSelector, useDispatch, shallowEqual } from 'react-redux';
+import { batch } from 'react-redux';
const BSLayout1 = lazy(
() => import('../../Pages/BookingScreen/Template/BSLayout1/BSLayout1.jsx')
@@ -29,7 +30,6 @@ import {
getTemplateData,
GlobalPricingAppPricingName,
changetemplateData,
- PricingAppPricingNameData,
changeSessionData,
GlobalScanTemplate,
changeScanTemplate,
@@ -37,12 +37,12 @@ import {
import {
changeProductSubCategorie,
ChangeScreenSize,
- getConfigType,
+ getConfigTypeBookingType,
getLayoutCategories,
- getLayoutSubCategories,
+ // getLayoutSubCategories,
getUnpaidData,
GlobalFeatAddOnData,
- GlobalProductCategorie,
+ // GlobalProductCategorie,
} from '../../Features/BookingScreen/BookingData/BookingData.js';
import { getSession } from '../../Services/Others';
import { usePaymentOptions } from '../../Pages/BookingScreen/Template/PaymentOptions.js';
@@ -56,13 +56,16 @@ import Loader from '../../Components/Loader/Loader.jsx';
const BookingPage = () => {
const dispatch = useDispatch();
- const templateData = useSelector(getTemplateData);
- const ProdCat = useSelector(GlobalProductCategorie);
- console.log(templateData, 'templateData');
+ const templateData = useSelector(getTemplateData, shallowEqual);
const BookingLayout = templateData?.BookingLayout?.[0];
- const [ismounted, setIsmounted] = useState(false);
- const [templateLoaded, setTemplateLoaded] = useState(false);
- const PricingAppPricingName = useSelector(GlobalPricingAppPricingName);
+
+ const templateLoadedRef = useRef(
+ Object.keys(templateData)?.length > 0 ? true : false
+ );
+ const PricingAppPricingName = useSelector(
+ GlobalPricingAppPricingName,
+ shallowEqual
+ );
const CompId = getSession('CompId');
const BranchId = getSession('BranchId');
@@ -72,10 +75,8 @@ const BookingPage = () => {
const UserType = getSession('UserType');
const AuthToken = sessionStorage.getItem('auth');
const SessionMobileNo = getSession('MobileNo');
- const UserName = getSession("UserName");
- const SessionId =getSession("SessionId")
- const FeatureAddonData = useSelector(GlobalFeatAddOnData);
- const Scantemplatedata = useSelector(GlobalScanTemplate);
+ const FeatureAddonData = useSelector(GlobalFeatAddOnData, shallowEqual);
+ const Scantemplatedata = useSelector(GlobalScanTemplate, shallowEqual);
useEffect(() => {
if (BranchId) {
@@ -112,10 +113,8 @@ const BookingPage = () => {
} else {
dispatch(changeholddata([]));
}
- } catch {
- (err) => {
- console.log(err);
- };
+ } catch (err) {
+ console.log(err);
}
};
@@ -130,8 +129,6 @@ const BookingPage = () => {
AuthToken,
SessionMobileNo,
FeatureAddonData,
- UserName,
- SessionId
};
dispatch(changeSessionData(SessionData));
}, [BranchId, FeatureAddonData]);
@@ -143,254 +140,35 @@ const BookingPage = () => {
UserId: UserId,
});
- useEffect(() => {
- ProdCat &&
- dispatch(
- getLayoutSubCategories({
- CompId: CompId,
- BranchId: BranchId,
- AppId: AppId,
- ProdCat: ProdCat,
- })
- ).unwrap();
- }, [ProdCat]);
+ const initializeBookingPage = () => {
+ batch(() => {
+ dispatch(getConfigTypeBookingType({ TypeName: 'Booking Type' }));
+ dispatch(ChangeRedirectStatus(true));
+ dispatch(changeProductSubCategorie('NaN'));
+ dispatch(getLayoutCategories({ CompId, BranchId, AppId }));
+ });
+ };
useEffect(() => {
- dispatch(getConfigType({ TypeName: 'Booking Type' })).unwrap();
- dispatch(ChangeRedirectStatus(true));
- dispatch(changeProductSubCategorie('NaN'));
- dispatch(
- getLayoutCategories({ CompId: CompId, BranchId: BranchId, AppId: AppId })
- ).unwrap();
- let data;
- if (UserType === 'Super Admin' || UserType === 'Super Admin User') {
- data = {
- appId: AppId,
- compId: CompId,
- branchId: BranchId,
- };
- } else {
- data = {
- appId: AppId,
- userId: UserId,
- };
- }
+ initializeBookingPage();
+ }, [CompId, BranchId, AppId]);
+ useEffect(() => {
+ const handleUnload = () => {
+ const customerDisplayWindow = getCustomerDisplayWindow();
- dispatch(PricingAppPricingNameData(data)).unwrap();
+ if (customerDisplayWindow && !customerDisplayWindow.closed) {
+ customerDisplayWindow.postMessage({ type: 'refresh' }, '*');
+ }
+ };
+
+ window.addEventListener('beforeunload', handleUnload);
+
+ return () => {
+ window.removeEventListener('beforeunload', handleUnload);
+ };
}, []);
useEffect(() => {
- const fetchData = async (Plan) => {
- if (templateLoaded) return; // STOP duplicate calls
-
- const Data = { AppId, CompId, BranchId };
- if (
- Scantemplatedata?.Scantemplate &&
- Scantemplatedata?.changetemp == 'Combo'
- ) {
- console.log('dont want any changes');
- } else if (
- Scantemplatedata?.changetemp == 'Layout' &&
- (Scantemplatedata?.OldTemp == 'Combo1' ||
- Scantemplatedata?.OldTemp == 'Combo2')
- ) {
- let tempdata = {
- BookingLayout: [
- 'Layout2',
- [
- {
- TemplateOptionsId: 71805,
- OptionId: 45,
- OptionName: 'Category',
- },
- {
- TemplateOptionsId: 71807,
- OptionId: 47,
- OptionName: 'Card',
- },
- {
- TemplateOptionsId: 71808,
- OptionId: 48,
- OptionName: 'Billing',
- },
- {
- TemplateOptionsId: 71809,
- OptionId: 166,
- OptionName: 'Navbar',
- },
- ],
- ],
- BookingNavbar: [
- 'Navbar3',
- [
- {
- TemplateOptionsId: 71811,
- OptionId: 74,
- OptionName: 'Search',
- },
- {
- TemplateOptionsId: 71812,
- OptionId: 75,
- OptionName: 'RePrint',
- },
- {
- TemplateOptionsId: 71813,
- OptionId: 77,
- OptionName: 'QuickAdd',
- },
- {
- TemplateOptionsId: 71814,
- OptionId: 76,
- OptionName: 'DineIn',
- },
- {
- TemplateOptionsId: 71815,
- OptionId: 79,
- OptionName: 'TakeAway',
- },
- {
- TemplateOptionsId: 71816,
- OptionId: 80,
- OptionName: 'Offer',
- },
- {
- TemplateOptionsId: 71817,
- OptionId: 82,
- OptionName: 'ExtraCharge',
- },
- {
- TemplateOptionsId: 71825,
- OptionId: 130,
- OptionName: 'Hold',
- },
- {
- TemplateOptionsId: 71826,
- OptionId: 172,
- OptionName: 'AddCustomer',
- },
- ],
- ],
- BookingCategory: [
- 'Category5',
- [
- {
- TemplateOptionsId: 71818,
- OptionId: 95,
- OptionName: 'Image',
- },
- {
- TemplateOptionsId: 71819,
- OptionId: 96,
- OptionName: 'Background',
- },
- ],
- ],
- BookingCard: [
- 'Card4',
- [
- {
- TemplateOptionsId: 71821,
- OptionId: 117,
- OptionName: 'Background',
- },
- {
- TemplateOptionsId: 71822,
- OptionId: 119,
- OptionName: 'Price',
- },
- {
- TemplateOptionsId: 71823,
- OptionId: 120,
- OptionName: 'SmallImage',
- },
- {
- TemplateOptionsId: 71824,
- OptionId: 121,
- OptionName: 'ImageLeft',
- },
- ],
- ],
- BookingBilling: [
- 'StandardBilling',
- [
- {
- TemplateOptionsId: 71825,
- OptionId: 130,
- OptionName: 'Hold',
- },
- {
- TemplateOptionsId: 71825,
- OptionId: 130,
- OptionName: 'DineIn',
- },
- {
- TemplateOptionsId: 71826,
- OptionId: 171,
- OptionName: 'Background',
- },
- {
- TemplateOptionsId: 71826,
- OptionId: 172,
- OptionName: 'AddCustomer',
- },
-
- {
- TemplateOptionsId: 71828,
- OptionId: 210,
- OptionName: 'Sl.No',
- },
- {
- TemplateOptionsId: 71829,
- OptionId: 211,
- OptionName: 'Item',
- },
- {
- TemplateOptionsId: 71830,
- OptionId: 214,
- OptionName: 'Quantity',
- },
- {
- TemplateOptionsId: 71831,
- OptionId: 216,
- OptionName: 'Amount',
- },
- {
- TemplateOptionsId: 71832,
- OptionId: 217,
- OptionName: 'Edit',
- },
- {
- TemplateOptionsId: 71833,
- OptionId: 218,
- OptionName: 'Delete',
- },
- ],
- ],
- };
- await dispatch(
- changeScanTemplate({
- Scantemplate: false,
- changetemp: Scantemplatedata?.changetemp,
- Template: tempdata,
- OldTemp: Scantemplatedata?.OldTemp,
- })
- );
- // setIsmounted(false)
- } else {
- const templateResponse = await dispatch(
- getTemplate({ CompId, BranchId, AppId })
- ).unwrap();
- dispatch(getPrintSelectionComponentData(Data)).unwrap();
- setTemplateLoaded(true);
- if (
- !templateResponse?.data?.data ||
- templateResponse.data.data.length === 0
- ) {
- Professional(Plan);
- }
- }
- // Check if template data is empty or not
- };
const Advance = PricingAppPricingName?.some(
(item) => item.PricingName === 'Premium'
);
@@ -401,11 +179,7 @@ const BookingPage = () => {
(item) => item?.FeatureAddonName?.toLowerCase() === 'customized template'
);
if (PricingAppPricingName?.length === 0) return;
- console.log(
- PricingAppPricingName,
- FeatureAddonData,
- 'FeatureAddonDataFeatureAddonData'
- );
+
if (PricingAppPricingName?.length > 0) {
if (Advance) {
fetchData('Advance');
@@ -422,23 +196,217 @@ const BookingPage = () => {
}
}
}, [PricingAppPricingName]);
- useEffect(() => {
- const handleUnload = () => {
- const customerDisplayWindow = getCustomerDisplayWindow(); // Retrieve from your state/redux
- if (customerDisplayWindow && !customerDisplayWindow.closed) {
- customerDisplayWindow.postMessage({ type: 'refresh' }, '*');
+ const fetchData = async (Plan) => {
+ if (templateLoadedRef.current) return; // STOP duplicate calls
+
+ const Data = { AppId, CompId, BranchId };
+ if (
+ Scantemplatedata?.Scantemplate &&
+ Scantemplatedata?.changetemp == 'Combo'
+ ) {
+ console.log('dont want any changes');
+ } else if (
+ Scantemplatedata?.changetemp == 'Layout' &&
+ (Scantemplatedata?.OldTemp == 'Combo1' ||
+ Scantemplatedata?.OldTemp == 'Combo2')
+ ) {
+ let tempdata = {
+ BookingLayout: [
+ 'Layout2',
+ [
+ {
+ TemplateOptionsId: 71805,
+ OptionId: 45,
+ OptionName: 'Category',
+ },
+ {
+ TemplateOptionsId: 71807,
+ OptionId: 47,
+ OptionName: 'Card',
+ },
+ {
+ TemplateOptionsId: 71808,
+ OptionId: 48,
+ OptionName: 'Billing',
+ },
+ {
+ TemplateOptionsId: 71809,
+ OptionId: 166,
+ OptionName: 'Navbar',
+ },
+ ],
+ ],
+ BookingNavbar: [
+ 'Navbar3',
+ [
+ {
+ TemplateOptionsId: 71811,
+ OptionId: 74,
+ OptionName: 'Search',
+ },
+ {
+ TemplateOptionsId: 71812,
+ OptionId: 75,
+ OptionName: 'RePrint',
+ },
+ {
+ TemplateOptionsId: 71813,
+ OptionId: 77,
+ OptionName: 'QuickAdd',
+ },
+ {
+ TemplateOptionsId: 71814,
+ OptionId: 76,
+ OptionName: 'DineIn',
+ },
+ {
+ TemplateOptionsId: 71815,
+ OptionId: 79,
+ OptionName: 'TakeAway',
+ },
+ {
+ TemplateOptionsId: 71816,
+ OptionId: 80,
+ OptionName: 'Offer',
+ },
+ {
+ TemplateOptionsId: 71817,
+ OptionId: 82,
+ OptionName: 'ExtraCharge',
+ },
+ {
+ TemplateOptionsId: 71825,
+ OptionId: 130,
+ OptionName: 'Hold',
+ },
+ {
+ TemplateOptionsId: 71826,
+ OptionId: 172,
+ OptionName: 'AddCustomer',
+ },
+ ],
+ ],
+ BookingCategory: [
+ 'Category5',
+ [
+ {
+ TemplateOptionsId: 71818,
+ OptionId: 95,
+ OptionName: 'Image',
+ },
+ {
+ TemplateOptionsId: 71819,
+ OptionId: 96,
+ OptionName: 'Background',
+ },
+ ],
+ ],
+ BookingCard: [
+ 'Card4',
+ [
+ {
+ TemplateOptionsId: 71821,
+ OptionId: 117,
+ OptionName: 'Background',
+ },
+ {
+ TemplateOptionsId: 71822,
+ OptionId: 119,
+ OptionName: 'Price',
+ },
+ {
+ TemplateOptionsId: 71823,
+ OptionId: 120,
+ OptionName: 'SmallImage',
+ },
+ {
+ TemplateOptionsId: 71824,
+ OptionId: 121,
+ OptionName: 'ImageLeft',
+ },
+ ],
+ ],
+ BookingBilling: [
+ 'StandardBilling',
+ [
+ {
+ TemplateOptionsId: 71825,
+ OptionId: 130,
+ OptionName: 'Hold',
+ },
+ {
+ TemplateOptionsId: 71825,
+ OptionId: 130,
+ OptionName: 'DineIn',
+ },
+ {
+ TemplateOptionsId: 71826,
+ OptionId: 171,
+ OptionName: 'Background',
+ },
+ {
+ TemplateOptionsId: 71826,
+ OptionId: 172,
+ OptionName: 'AddCustomer',
+ },
+
+ {
+ TemplateOptionsId: 71828,
+ OptionId: 210,
+ OptionName: 'Sl.No',
+ },
+ {
+ TemplateOptionsId: 71829,
+ OptionId: 211,
+ OptionName: 'Item',
+ },
+ {
+ TemplateOptionsId: 71830,
+ OptionId: 214,
+ OptionName: 'Quantity',
+ },
+ {
+ TemplateOptionsId: 71831,
+ OptionId: 216,
+ OptionName: 'Amount',
+ },
+ {
+ TemplateOptionsId: 71832,
+ OptionId: 217,
+ OptionName: 'Edit',
+ },
+ {
+ TemplateOptionsId: 71833,
+ OptionId: 218,
+ OptionName: 'Delete',
+ },
+ ],
+ ],
+ };
+ await dispatch(
+ changeScanTemplate({
+ Scantemplate: false,
+ changetemp: Scantemplatedata?.changetemp,
+ Template: tempdata,
+ OldTemp: Scantemplatedata?.OldTemp,
+ })
+ );
+ // setIsmounted(false)
+ } else {
+ const templateResponse = await dispatch(
+ getTemplate({ CompId, BranchId, AppId })
+ ).unwrap();
+ dispatch(getPrintSelectionComponentData(Data)).unwrap();
+ templateLoadedRef.current = true;
+ if (
+ !templateResponse?.data?.data ||
+ templateResponse.data.data.length === 0
+ ) {
+ //Professional(Plan);
}
- };
-
- // Add beforeunload listener when the component mounts
- window.addEventListener('beforeunload', handleUnload);
-
- // Clean up the event listener when the component unmounts
- return () => {
- window.removeEventListener('beforeunload', handleUnload);
- };
- }, []);
-
+ }
+ // Check if template data is empty or not
+ };
const Professional = async (data) => {
const tempData = {
SelectedApplication: AppId,
@@ -449,23 +417,6 @@ const BookingPage = () => {
dispatch(changetemplateData(tempData));
};
- if (ismounted)
- return (
-
-
-
- );
return (
{Object.keys(templateData)?.length > 0 ? (
@@ -484,6 +435,7 @@ const BookingPage = () => {
overflow: 'hidden',
flexDirection: 'column',
fontWeight: '500',
+ bottom: '3rem',
}}
>
Loading Layout...
@@ -503,10 +455,10 @@ const BookingPage = () => {
>
) : (
- <>{/* {Advance ?
Loading...
: null} */}>
+
)}
);
};
-export default BookingPage;
+export default memo(BookingPage);
diff --git a/src/Pages/BookingScreen/Components/MainPage/SelectionComponent.jsx b/src/Pages/BookingScreen/Components/MainPage/SelectionComponent.jsx
index 29dc690..376df17 100644
--- a/src/Pages/BookingScreen/Components/MainPage/SelectionComponent.jsx
+++ b/src/Pages/BookingScreen/Components/MainPage/SelectionComponent.jsx
@@ -1,14 +1,17 @@
-import React, { useEffect, useRef, useState, useCallback, forwardRef, useImperativeHandle } from 'react';
+import React, {
+ useEffect,
+ useRef,
+ useState,
+ useCallback,
+ forwardRef,
+ useImperativeHandle,
+} from 'react';
import { useSelector, useDispatch } from 'react-redux';
import WebFont from 'webfontloader';
import { SwatchesPicker } from 'react-color';
import { DefaultModal } from '../../../../Components/Modal/DefaultModal';
import { RadioGrpButton } from '../../../../Components/Forms/RadioGroup.jsx';
-import {
-
- CloseOutlined,
- ArrowRightOutlined,
-} from '@ant-design/icons';
+import { CloseOutlined, ArrowRightOutlined } from '@ant-design/icons';
import { BiSkipPrevious } from 'react-icons/bi';
import { BiSkipNext } from 'react-icons/bi';
import { Modal, Form } from 'antd';
@@ -113,12 +116,15 @@ import {
import { getPreferenceData } from '../../../../Features/BookingScreen/BookingData/BookingData.js';
import { useAuth } from '../../../../AuthContext.jsx';
import { HiOutlineSquares2X2, HiSquaresPlus } from 'react-icons/hi2';
-import { ApplicationPreferences, getCommonAppPreference } from '../../../../Features/BrachLogin/BranchLogin.js';
+import {
+ ApplicationPreferences,
+ getCommonAppPreference,
+} from '../../../../Features/BrachLogin/BranchLogin.js';
import { TbLayoutNavbar } from 'react-icons/tb';
import { HiMenuAlt1 } from 'react-icons/hi';
-import { IoMdAdd } from "react-icons/io";
-import { LuCreditCard } from "react-icons/lu";
-import { IoReceiptOutline } from "react-icons/io5";
+import { IoMdAdd } from 'react-icons/io';
+import { LuCreditCard } from 'react-icons/lu';
+import { IoReceiptOutline } from 'react-icons/io5';
const subDirectory = import.meta.env.BASE_URL;
const SelectionComponent = forwardRef((props, ref) => {
@@ -175,12 +181,22 @@ const SelectionComponent = forwardRef((props, ref) => {
SelectedGlobalSubCatgColorDetail
);
const DefaultThemes = useSelector(GlobalDefaultTheme);
- const SelectedTheme = useSelector(GlobalSelectedTheme)
+ const SelectedTheme = useSelector(GlobalSelectedTheme);
const activeTheme = useSelector(GlobalActiveTheme);
const appPreferences = useSelector(ApplicationPreferences);
- const bookingTypePreference = appPreferences?.find((preference) => preference?.PreferredCatName === 'Booking Type')?.PreferenceCatDetails
- const dinePreference = bookingTypePreference?.find((type) => type?.PreferredSubCatName?.toLowerCase() === "dine in" && type?.PreferredStatus === 'Y')
- const takeAwayPreference = bookingTypePreference?.find((type) => type?.PreferredSubCatName?.toLowerCase() === "take away" && type?.PreferredStatus === 'Y')
+ const bookingTypePreference = appPreferences?.find(
+ (preference) => preference?.PreferredCatName === 'Booking Type'
+ )?.PreferenceCatDetails;
+ const dinePreference = bookingTypePreference?.find(
+ (type) =>
+ type?.PreferredSubCatName?.toLowerCase() === 'dine in' &&
+ type?.PreferredStatus === 'Y'
+ );
+ const takeAwayPreference = bookingTypePreference?.find(
+ (type) =>
+ type?.PreferredSubCatName?.toLowerCase() === 'take away' &&
+ type?.PreferredStatus === 'Y'
+ );
const AppId = getSession('AppId');
const UserId = getSession('UserId');
const CompId = getSession('CompId');
@@ -230,7 +246,6 @@ const SelectionComponent = forwardRef((props, ref) => {
const [SelectedBillingTableId, setSelectedBillingTableId] = useState(null);
const [ShowDropDownData, SetShowDropDownData] = useState([]);
-
//navbarcheck boxes
const [NavBarCheckList, setNavBarCheckList] = useState([]);
const [SelectedNavCheckValues, setSelectedNavCheckValues] = useState([]);
@@ -399,9 +414,19 @@ const SelectionComponent = forwardRef((props, ref) => {
useEffect(() => {
if (activeTheme == 'default') {
if (Object.keys(DefaultThemes)?.length > 0) {
- dispatch(changeSelectedTheme({ ThemeId: DefaultThemes?.[0]?.TemplatePreferenceId, ThemeName: DefaultThemes?.[0]?.ThemeName }));
+ dispatch(
+ changeSelectedTheme({
+ ThemeId: DefaultThemes?.[0]?.TemplatePreferenceId,
+ ThemeName: DefaultThemes?.[0]?.ThemeName,
+ })
+ );
settemplateData(DefaultThemes?.[0]);
- dispatch(changeThemeCreation({ formtype: 'edit', editdata: DefaultThemes?.[0] }));
+ dispatch(
+ changeThemeCreation({
+ formtype: 'edit',
+ editdata: DefaultThemes?.[0],
+ })
+ );
} else {
dispatch(changeSelectedTheme({}));
settemplateData({});
@@ -438,7 +463,7 @@ const SelectionComponent = forwardRef((props, ref) => {
).unwrap();
if (tempdetail?.data?.statusCode == 1) {
- dispatch(changeActiveTheme("customised"));
+ dispatch(changeActiveTheme('customised'));
} else {
setTemptemplatedata(true);
}
@@ -459,7 +484,7 @@ const SelectionComponent = forwardRef((props, ref) => {
};
const getThemesData = async () => {
- // let themeresponse =
+ // let themeresponse =
await dispatch(getThemes()).unwrap();
// if (themeresponse.data?.statusCode === 1) {
// let themedatalist = themeresponse.data?.data?.filter(
@@ -496,7 +521,6 @@ const SelectionComponent = forwardRef((props, ref) => {
}, [templateData1, selthemeData, activeTheme]);
useEffect(() => {
if (Object.keys(templateData)?.length > 0) {
-
setEditTemplateData();
} else {
ClearAllComponentStates();
@@ -764,7 +788,7 @@ const SelectionComponent = forwardRef((props, ref) => {
useEffect(() => {
if (templateData && BillingTableData?.length > 0) {
- console.log(BillingTableData?.length, "BillingTableData?.length")
+ console.log(BillingTableData?.length, 'BillingTableData?.length');
const editCardVal = BillingTableData?.filter(
(item) => item.ComponentName == templateData?.['BookingBilling']?.[0]
);
@@ -1062,16 +1086,22 @@ const SelectionComponent = forwardRef((props, ref) => {
const GetNavbarFun = async () => {
const gettingNavbarData = await dispatch(getNavbar()).unwrap();
if (gettingNavbarData?.data?.statusCode === 1) {
- setNavbarData(gettingNavbarData.data?.data?.map((navbar) => {
- return {
- ...navbar,
- ComponentOptionsDetails: navbar?.ComponentOptionsDetails
- ?.filter((component) =>
- !((component?.OptionName === 'DineIn' && dinePreference === undefined) ||
- (component?.OptionName === 'TakeAway' && takeAwayPreference === undefined))
- )
- }
- }));
+ setNavbarData(
+ gettingNavbarData.data?.data?.map((navbar) => {
+ return {
+ ...navbar,
+ ComponentOptionsDetails: navbar?.ComponentOptionsDetails?.filter(
+ (component) =>
+ !(
+ (component?.OptionName === 'DineIn' &&
+ dinePreference === undefined) ||
+ (component?.OptionName === 'TakeAway' &&
+ takeAwayPreference === undefined)
+ )
+ ),
+ };
+ })
+ );
}
};
const GetCategoryFun = async () => {
@@ -1122,31 +1152,43 @@ const SelectionComponent = forwardRef((props, ref) => {
const GetCombo1Navbar = async () => {
const gettingCombo1NavbarData = await dispatch(getCombo1Navbar()).unwrap();
if (gettingCombo1NavbarData?.data?.statusCode === 1) {
- setNavbarData(gettingCombo1NavbarData?.data?.data?.map((navbar) => {
- return {
- ...navbar,
- ComponentOptionsDetails: navbar?.ComponentOptionsDetails
- ?.filter((component) =>
- !((component?.OptionName === 'DineIn' && dinePreference === undefined) ||
- (component?.OptionName === 'TakeAway' && takeAwayPreference === undefined))
- )
- }
- }));
+ setNavbarData(
+ gettingCombo1NavbarData?.data?.data?.map((navbar) => {
+ return {
+ ...navbar,
+ ComponentOptionsDetails: navbar?.ComponentOptionsDetails?.filter(
+ (component) =>
+ !(
+ (component?.OptionName === 'DineIn' &&
+ dinePreference === undefined) ||
+ (component?.OptionName === 'TakeAway' &&
+ takeAwayPreference === undefined)
+ )
+ ),
+ };
+ })
+ );
}
};
const GetCombo2Navbar = async () => {
const gettingCombo2NavbarData = await dispatch(getCombo2Navbar()).unwrap();
if (gettingCombo2NavbarData?.data?.statusCode === 1) {
- setNavbarData(gettingCombo2NavbarData?.data?.data?.map((navbar) => {
- return {
- ...navbar,
- ComponentOptionsDetails: navbar?.ComponentOptionsDetails
- ?.filter((component) =>
- !((component?.OptionName === 'DineIn' && dinePreference === undefined) ||
- (component?.OptionName === 'TakeAway' && takeAwayPreference === undefined))
- )
- }
- }));
+ setNavbarData(
+ gettingCombo2NavbarData?.data?.data?.map((navbar) => {
+ return {
+ ...navbar,
+ ComponentOptionsDetails: navbar?.ComponentOptionsDetails?.filter(
+ (component) =>
+ !(
+ (component?.OptionName === 'DineIn' &&
+ dinePreference === undefined) ||
+ (component?.OptionName === 'TakeAway' &&
+ takeAwayPreference === undefined)
+ )
+ ),
+ };
+ })
+ );
}
};
@@ -1318,15 +1360,20 @@ const SelectionComponent = forwardRef((props, ref) => {
],
})
);
- setBillTableCheckList(BillTableItems?.map((billItem) => {
- return {
- ...billItem,
- ComponentOptionsDetails: billItem?.ComponentOptionsDetails
- ?.filter((component) =>
- !(component?.OptionName === 'UnpaidBill' && dinePreference === undefined)
- )
- }
- }));
+ setBillTableCheckList(
+ BillTableItems?.map((billItem) => {
+ return {
+ ...billItem,
+ ComponentOptionsDetails: billItem?.ComponentOptionsDetails?.filter(
+ (component) =>
+ !(
+ component?.OptionName === 'UnpaidBill' &&
+ dinePreference === undefined
+ )
+ ),
+ };
+ })
+ );
const itemOption = BillTableItems[0]?.ComponentOptionsDetails?.find(
(option) => option.OptionName === 'Item'
@@ -2278,7 +2325,7 @@ const SelectionComponent = forwardRef((props, ref) => {
});
};
const validateFontsTable = async (values) => {
- console.log(values,"table font")
+ console.log(values, 'table font');
const apiUrl = `https://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyDP1HqNkLI53iIAH-SB9_mt_24QdkUZ_24`;
fetch(apiUrl)
.then((response) => response.json())
@@ -2674,7 +2721,7 @@ const SelectionComponent = forwardRef((props, ref) => {
// onfinish function
const onfinish = async (values) => {
- console.log(values, "valuesvalues")
+ console.log(values, 'valuesvalues');
setFirstOnClick(true);
let colorOriginalArray = [
values.CatColor,
@@ -2734,12 +2781,12 @@ const SelectionComponent = forwardRef((props, ref) => {
ShowDropDownData?.find((a) => a.OptionName === 'SubCategory')
? tempData.push({
- ComponentId: SelectedSubCategoryId,
- ComponentDetails:
- SelectedSubCategoryCheckList != undefined
- ? SelectedSubCategoryCheckList
- : [],
- })
+ ComponentId: SelectedSubCategoryId,
+ ComponentDetails:
+ SelectedSubCategoryCheckList != undefined
+ ? SelectedSubCategoryCheckList
+ : [],
+ })
: ''; // Shifayath Date:27/12/2023
tempData.push({
@@ -2793,8 +2840,10 @@ const SelectionComponent = forwardRef((props, ref) => {
setMessageData('Template Details Added Successfully');
setFirstOnClick(false);
}
- dispatch(changeScanTemplate({}))
-
+ dispatch(changeScanTemplate({}));
+ await dispatch(
+ getTemplate({ CompId: CompId, BranchId: BranchId, AppId: AppId })
+ );
} else {
setMessageType('error');
setMessageData(response?.data?.response);
@@ -2963,7 +3012,12 @@ const SelectionComponent = forwardRef((props, ref) => {
onComplete={onComplete}
/>