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} />
-
+ {/*
{ Layout and Feature Settings
- {!( - Object.keys(templateData)?.length == 0 - ) && ( -
-

Layout

+ {!(Object.keys(templateData)?.length == 0) && ( +
+

Layout

- - - ({ - value: option.ComponentId, - label: option.ComponentName, - }))} - label="Layout" - onChangeFunction={selectLayout} - className="field-DropDown-Selection" - isOnchanges={SelectedLayoutId ? true : false} - valueData={SelectedLayoutId} - /> - -
- )} + + ({ + value: option.ComponentId, + label: option.ComponentName, + }))} + label="Layout" + onChangeFunction={selectLayout} + className="field-DropDown-Selection" + isOnchanges={SelectedLayoutId ? true : false} + valueData={SelectedLayoutId} + /> + +
+ )} {
-
-
- - {selectOverallSelected == true && ( -
-
- - ({ - value: option.ColorId, - label: ( -
-
- -     - -
-
{option.ThemeName}
-
- ), - }) - )} - labelChange={true} - label={ -

- Overall Background -

- } - className="field-DropDown-Selection" - onChangeFunction={selectLayoutOverallColor} - isOnchanges={ - dropdownLayoutOverallColor ? true : false - } - valueData={dropdownLayoutOverallColor} - /> -
-
-
- Add - +
- )} -
+ + + + +
+ +
+ + {selectOverallSelected == true && ( +
+
+ + ({ + value: option.ColorId, + label: ( +
+
+ +     + +
+
{option.ThemeName}
+
+ ), + }) + )} + labelChange={true} + label={ +

+ Overall Background +

+ } + className="field-DropDown-Selection" + onChangeFunction={selectLayoutOverallColor} + isOnchanges={ + dropdownLayoutOverallColor ? true : false + } + valueData={dropdownLayoutOverallColor} + /> +
+
+
+ Add + +
+
+ )} - )} + + )}
{NavBarCheckList?.length > 0 && @@ -3527,7 +3584,7 @@ const SelectionComponent = forwardRef((props, ref) => { Selected NavBar : - {NavBarCheckList[0]?.ComponentName} + {NavBarCheckList[0]?.ComponentName}
@@ -3550,18 +3607,18 @@ const SelectionComponent = forwardRef((props, ref) => { value.OptionName === 'Hold' && NavHoldButton ? true : value.OptionName === 'AddCustomer' && - NavAddCustomerButton + NavAddCustomerButton ? true : value.OptionName === 'DineIn' && - (GlobalPreferenceData?.SettingValue !== - 'Y' || - GlobalPreferenceData?.length === 0) + (GlobalPreferenceData?.SettingValue !== + 'Y' || + GlobalPreferenceData?.length === 0) ? true : value.OptionName === 'Search' ? true : false } - // onClick={() => holdoption(value.OptionName)} + // onClick={() => holdoption(value.OptionName)} > {value.OptionName} @@ -3578,7 +3635,7 @@ const SelectionComponent = forwardRef((props, ref) => { Selected Category: - {CategoryCheckList[0]?.ComponentName} + {CategoryCheckList[0]?.ComponentName} @@ -3599,7 +3656,7 @@ const SelectionComponent = forwardRef((props, ref) => { key={value?.OptionId} disabled={ value.OptionName === 'ImageRight' && - !CatImageSelection + !CatImageSelection ? true : false } @@ -3616,14 +3673,14 @@ const SelectionComponent = forwardRef((props, ref) => { )} -
+
@@ -3636,7 +3693,7 @@ const SelectionComponent = forwardRef((props, ref) => { }, ]} > -

+

Category Font

{ />
-
+
Add - + { display: 'flex', gap: '1rem', flexWrap: 'nowrap', - alignItems: "center" + alignItems: 'center', }} >
@@ -3730,7 +3787,7 @@ const SelectionComponent = forwardRef((props, ref) => { }, ]} > -

+

Category Background Color

{ />
-
+
Add - +
@@ -3878,7 +3935,7 @@ const SelectionComponent = forwardRef((props, ref) => { }, ]} > -

+

Category Overall-Background

@@ -3936,12 +3993,12 @@ const SelectionComponent = forwardRef((props, ref) => { />
-
+
Add - +
@@ -3956,7 +4013,8 @@ const SelectionComponent = forwardRef((props, ref) => { Selected SubCategory: - {SubCategoryCheckList[0]?.ComponentName} + {' '} + {SubCategoryCheckList[0]?.ComponentName}
@@ -3982,12 +4040,8 @@ const SelectionComponent = forwardRef((props, ref) => { )} -
-
+
+
{ />
-
+
Add { />
-
+
Add { />
-
+
Add { Selected Card: - {CardCheckList[0]?.ComponentName} + {CardCheckList[0]?.ComponentName}
@@ -4445,14 +4508,14 @@ const SelectionComponent = forwardRef((props, ref) => { disabled={ !SmallImage ? SelectAllPositionImage?.includes( - value?.OptionId - ) + value?.OptionId + ) ? true : false : SelectfliterPositionImage?.length < 4 ? SelectfliterPositionImage.includes( - value?.OptionId - ) + value?.OptionId + ) ? true : false : '' @@ -4464,12 +4527,8 @@ const SelectionComponent = forwardRef((props, ref) => { )} -
-
+
+
{ }, ]} > -

+

Card Font

{ />
-
+
Add { display: 'flex', gap: '1rem', flexWrap: 'nowrap', - alignItems: "center" + alignItems: 'center', }} >
@@ -4575,7 +4637,7 @@ const SelectionComponent = forwardRef((props, ref) => { }, ]} > -

+

Card Background Color

{ />
-
+
Add - +
@@ -4724,7 +4786,7 @@ const SelectionComponent = forwardRef((props, ref) => { }, ]} > -

+

Card Overall-Background

{ />
-
+
Add - +
@@ -4905,7 +4967,8 @@ const SelectionComponent = forwardRef((props, ref) => { Selected BillTable:{' '} - {BillTableCheckList[0]?.ComponentName} + {' '} + {BillTableCheckList[0]?.ComponentName}
@@ -4929,12 +4992,12 @@ const SelectionComponent = forwardRef((props, ref) => { value.OptionName === 'Hold' && HoldButton ? true : value.OptionName === 'AddCustomer' && - AddCustomerButton + AddCustomerButton ? true : value.OptionName === 'Item' ? true : value.OptionName === 'UnpaidBill' && - !DineInChecked + !DineInChecked ? true : false } @@ -4945,12 +5008,8 @@ const SelectionComponent = forwardRef((props, ref) => { )} -
-
+
+
{ }, ]} > -

+

BillTable Font

{ />
-
+
Add - - +
-
-
- +
+
+ { + await validateSafeInput(value); // To block HTML tags & SQL keywords + return Promise.resolve(); }, - { - validator: async (_, value) => { - await validateSafeInput(value); // To block HTML tags & SQL keywords - return Promise.resolve(); - }, - }, - ]} - > - - -
+ }, + ]} + > + +
-

- * Google Fonts Only -

- - } - handleCancel={TablehandleCancel} - handleSubmit={TablehandleSubmit} - buttonText="SAVE" - /> +
+

+ * Google Fonts Only +

+ + } + handleCancel={TablehandleCancel} + handleSubmit={TablehandleSubmit} + buttonText="SAVE" + />
{SelectedBillTableCheckValues?.filter( (item) => @@ -5043,7 +5101,7 @@ const SelectionComponent = forwardRef((props, ref) => { display: 'flex', gap: '1rem', flexWrap: 'nowrap', - alignItems: "center" + alignItems: 'center', }} >
@@ -5056,7 +5114,7 @@ const SelectionComponent = forwardRef((props, ref) => { }, ]} > -

+

BillTable Background Color

{ />
-
+
Add - +
@@ -5194,7 +5252,7 @@ const SelectionComponent = forwardRef((props, ref) => { display: 'flex', gap: '1rem', flexWrap: 'nowrap', - alignItems: "center" + alignItems: 'center', }} >
@@ -5207,7 +5265,7 @@ const SelectionComponent = forwardRef((props, ref) => { }, ]} > -

+

BillTable Overall-Background

{ />
-
+
Add { // (empData?.UpdateAccess === "Y" || SAAccessCommonMaster?.UpdateAccess === "Y") && // Object.keys(templateData)?.length > 0 // ))} - icon={} + icon={} htmlType={true} />
diff --git a/src/Pages/BookingScreen/Components/OtherConponents/Reprint/BSReprint.jsx b/src/Pages/BookingScreen/Components/OtherConponents/Reprint/BSReprint.jsx index 0c73699..eb3b0d8 100644 --- a/src/Pages/BookingScreen/Components/OtherConponents/Reprint/BSReprint.jsx +++ b/src/Pages/BookingScreen/Components/OtherConponents/Reprint/BSReprint.jsx @@ -30,7 +30,7 @@ import { SelectedPrintTemplate, GlobalPrinterMappingDtls, getPrinterMappingDetails, - getPrintSelectionComponentData, + // getPrintSelectionComponentData, } from '../../../../../Features/ThemeChange/ThemeChange'; import FormHeader from '../../../../../Pages/PageComponents/FormHeader'; import { ArrowRightOutlined } from '@ant-design/icons'; @@ -82,10 +82,14 @@ import { import { TbSettingsCog } from 'react-icons/tb'; import { useQuery, useQueryClient } from '@tanstack/react-query'; import { axiosRetailInstanceData } from '../../../../../Features/AuthenicationToken/AuthenticationToken.js'; -import { MdEdit } from "react-icons/md"; +import { MdEdit } from 'react-icons/md'; import { v4 as uuidv4 } from 'uuid'; import { changeOrderOfferDetail } from '../../../../../Features/Offer/Offer.js'; -import { ChangeFullFreeProductList, changeFullOfferAppliedProducts, changeLoyaltyConsumedQuantities } from '../../../../../Features/Offer/Offernew/BookingOffernew.js'; +import { + ChangeFullFreeProductList, + changeFullOfferAppliedProducts, + changeLoyaltyConsumedQuantities, +} from '../../../../../Features/Offer/Offernew/BookingOffernew.js'; import { ChangeTotalAmount } from '../../../../../Features/ExteraCharges/ExtraCharges.js'; import { Radio } from 'antd'; import ReprintPDFDataShare from './ReprintPDFDataShare.jsx'; @@ -93,7 +97,7 @@ import { ImShare } from 'react-icons/im'; const RetailApiurl = import.meta.env.ENV_API_URL; -function BSReprint({ setOpenModel = () => { } }) { +function BSReprint({ setOpenModel = () => {} }) { const dispatch = useDispatch(); const queryClient = useQueryClient(); const appPreferences = useSelector(ApplicationPreferences); @@ -167,7 +171,7 @@ function BSReprint({ setOpenModel = () => { } }) { const AuthToken = sessionStorage.getItem('auth'); const SessionMobileNo = getSession('MobileNo'); const [dateStrings, setDateStrings] = useState([]); - const [type, setType] = useState("Sales"); + const [type, setType] = useState('Sales'); const [showShareModal, setShowShareModal] = useState(false); // ---- 1. Fetch Function ---- const fetchData = async ({ queryKey }) => { @@ -180,7 +184,7 @@ function BSReprint({ setOpenModel = () => { } }) { OrderFromDate: dates?.[0] ?? '', OrderToDate: dates?.[1] ?? '', PageNumber: page, - Type: type + Type: type, }) ).unwrap(); if (Response?.data?.statusCode === 1) { @@ -263,9 +267,8 @@ function BSReprint({ setOpenModel = () => { } }) { // UserId: UserId, }; dispatch(getPrinterMappingDetails(data)).unwrap(); - const Data1 = { AppId, CompId, BranchId }; - dispatch(getPrintSelectionComponentData(Data1)).unwrap(); - + // const Data1 = { AppId, CompId, BranchId }; + // dispatch(getPrintSelectionComponentData(Data1)).unwrap(); }, []); const handleDateChange = (dates, dateStrings) => { @@ -604,7 +607,7 @@ function BSReprint({ setOpenModel = () => { } }) { const selectedStyle = stylesMap[ - printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle + printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle ]; if (selectedStyle) { if (data === 'without') { @@ -950,9 +953,8 @@ function BSReprint({ setOpenModel = () => { } }) { onClick={async (e) => await handleEditBill(e, row)} /> ), - } + }, // ] : []) - , { title: () => (
{ } }) { const mutiplePrint = async (printType) => { setIsProcessing(true); setProcessingProgress(0); + const result = await MobileMultiPdfPrint({ printerTemplateStyle, printDatas, @@ -1252,15 +1255,16 @@ function BSReprint({ setOpenModel = () => { } }) { const isWeightScale = item?.ScaleType === 'weight'; if (isWeightScale) { - return acc + ( - Weightasquantity + return ( + acc + + (Weightasquantity ? Math.round(Number(item?.SalesQty || item?.OrderQty || 0)) - : 1 + : 1) ); } return acc + Math.round(Number(item?.SalesQty || item?.OrderQty || 0)); - }, 0) + }, 0); const widthOutTexAmt = table2Data?.[0]?.TaxDetails?.reduce( (sum, item) => sum + (item?.WithOutTaxAmount || 0), @@ -1292,7 +1296,7 @@ function BSReprint({ setOpenModel = () => { } }) { OrderQty: item?.SalesQty, OrderRate: item?.Rate, SellingPrice: item?.Rate, - TaxPercentage: (item?.ProdTaxPercentage || 0) + TaxPercentage: item?.ProdTaxPercentage || 0, // TotalAmt: formatAmount((item.TotalAmt - item.OfferValue)), })); @@ -1302,14 +1306,10 @@ function BSReprint({ setOpenModel = () => { } }) { if (RefDetails?.[0]?.OfferAppliedProductList) { dispatch( - changeFullOfferAppliedProducts( - RefDetails[0]?.OfferAppliedProductList - ) + changeFullOfferAppliedProducts(RefDetails[0]?.OfferAppliedProductList) ); } - - if (CustSuppId) { let res = await dispatch( getCustomerForHold({ @@ -1331,8 +1331,9 @@ function BSReprint({ setOpenModel = () => { } }) { } if (res?.data?.statusCode === 1) { - - const loyaltyFreeProductOfferApplied = (RefDetails?.[0]?.OfferAppliedProductList || [])?.filter( + const loyaltyFreeProductOfferApplied = ( + RefDetails?.[0]?.OfferAppliedProductList || [] + )?.filter( (off) => off?.FreeProductsList?.OfferMode === 'L' && off?.TableUniqueName === 'FreeProduct' @@ -1343,14 +1344,20 @@ function BSReprint({ setOpenModel = () => { } }) { ); if (customerDetails) { - const { CustId, CustName, CustMobile, LoyaltyPointsDetail, TotalLoyaltyPoints } = customerDetails; + const { + CustId, + CustName, + CustMobile, + LoyaltyPointsDetail, + TotalLoyaltyPoints, + } = customerDetails; const data = { CustId: CustId, CustName: CustName, label: CustName ? CustName : CustMobile, value: CustMobile, LoyaltyPointsDetail: LoyaltyPointsDetail, - TotalLoyaltyPoints: TotalLoyaltyPoints + TotalLoyaltyPoints: TotalLoyaltyPoints, }; dispatch(changeOrderOfferDetail([...OrderOfferDetails])); @@ -1383,7 +1390,6 @@ function BSReprint({ setOpenModel = () => { } }) { console.log(loyaltyProdQuantities, 'loyaltyProdQuantities'); } } - } } await dispatch(changeOrderType('Hold')); @@ -1395,7 +1401,8 @@ function BSReprint({ setOpenModel = () => { } }) { await dispatch(changePreviousOrderPayment(OrderPaymentDtl)); await dispatch(changePreviousOrderOfferDetail(OrderOfferDetails)); dispatch(changeOrderCardDetails(updated)); - let temp = updated?.filter((item) => item.OrderType === 'E') + let temp = updated + ?.filter((item) => item.OrderType === 'E') .map((item) => item.InwardDtlId + ' ' + item.BookingTypeName); await dispatch(changeSelProdWiseEst(temp)); @@ -1406,11 +1413,11 @@ function BSReprint({ setOpenModel = () => { } }) { await dispatch(changeEstimateBooking('Sales')); await dispatch(ChangeOverAllDiscSales(parseFloat(OverallDisc))); } - } + }; const typeOptions = [ - { label: "Sales", value: "Sales" }, - { label: "Estimate", value: "Est" }, + { label: 'Sales', value: 'Sales' }, + { label: 'Estimate', value: 'Est' }, ]; const typeChange = (e) => { @@ -1455,15 +1462,17 @@ function BSReprint({ setOpenModel = () => { } }) { />
- {preferenceEstimate &&
- -
} + {preferenceEstimate && ( +
+ +
+ )}
{ } }) { }} />
- setShowShareModal(true)} style={{ cursor: 'pointer' }} /> + setShowShareModal(true)} + style={{ cursor: 'pointer' }} + />
{selectedRows.length > 0 && ( @@ -1507,9 +1520,6 @@ function BSReprint({ setOpenModel = () => { } }) { onClick={() => mutiplePrint('whatsapp')} className="icon-whatsapp" /> - {/* */}
)}
@@ -1519,7 +1529,7 @@ function BSReprint({ setOpenModel = () => { } }) { {countOfProduct > 10 && ( { } }) {
))} - {showShareModal && setShowShareModal(false)} - />} + {showShareModal && ( + setShowShareModal(false)} + /> + )} ); } diff --git a/src/Pages/BookingScreen/Forms/DirectSale/DirectSale.jsx b/src/Pages/BookingScreen/Forms/DirectSale/DirectSale.jsx index 10ac37b..bfdd03f 100644 --- a/src/Pages/BookingScreen/Forms/DirectSale/DirectSale.jsx +++ b/src/Pages/BookingScreen/Forms/DirectSale/DirectSale.jsx @@ -1,75 +1,549 @@ -import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; -import { Table, Input, Select, Button } from 'antd'; -import { PlusOutlined, DeleteOutlined, SaveOutlined, PrinterOutlined } from '@ant-design/icons'; +import { + lazy, + Suspense, + useCallback, + useEffect, + useMemo, + useRef, + useState, +} from 'react'; +import { Input, Select, Button } from 'antd'; +import { + DeleteOutlined, + SaveOutlined, + PrinterOutlined, +} from '@ant-design/icons'; import { Tables } from '../../../../Components/Tables/Table.jsx'; import { useDispatch } from 'react-redux'; -import { postProductData, getDirectSaleProducts, getAllProductShortCodes, deleteProductData, getDirectSaleSearchedProduct } from '../../../../Features/ProductPage/ProductPage.js'; +import { + postProductData, + getDirectSaleProducts, + getAllProductShortCodes, + deleteProductData, + getDirectSaleSearchedProduct, +} from '../../../../Features/ProductPage/ProductPage.js'; import { getSession, printDiv } from '../../../../Services/Others.js'; import { Messages } from '../../../../Components/Notifications/Messages.jsx'; -import { FaStarOfLife } from "react-icons/fa6"; -import { IoMdRefresh } from "react-icons/io"; +import { FaStarOfLife } from 'react-icons/fa6'; +import { IoMdRefresh } from 'react-icons/io'; import StickerPrintModel from '../../../Product/StickerPrintModal.jsx'; import { getPageStyle, style } from '../../../Product/Printstyles.js'; -import { getBarcodeSessionsIDs, getBarcodeTemplate } from '../../../../Features/Barcode/Barcode.js'; -import { generateBarcode, generateQRCode, generateQRCodeCopy } from '../../../../Services/utils.js'; -import StickerPrintTemplates from '../../../Product/StickerTemplates.jsx'; +import { + getBarcodeSessionsIDs, + getBarcodeTemplate, +} from '../../../../Features/Barcode/Barcode.js'; +import { + generateBarcode, + generateQRCode, + generateQRCodeCopy, +} from '../../../../Services/utils.js'; import useBarcodeGenerator from './useBarcodeQRGenerator.js'; +// Jsx File +const StickerPrintTemplates = lazy( + () => import('../../../Product/StickerTemplates.jsx') +); +// SCss +import '../../../../Styles/BookingScreen/Components/OtherConponents/Reprint/BSReprint.scss'; +const DirectSale = ({ + UomData = [], + TaxData = [], + ProductTypeData = [], + ProdCatData = [], + ProdSubCatData = [], + SupplierData = [], + activeTab = null, +}) => { + const formRef = useRef(); + const tableRef = useRef(); + const searchInputRef = useRef(); + const dispatch = useDispatch(); + const [messageType, setMessageType] = useState(null); + const [messageData, setMessageData] = useState(null); + const [currentPage, setCurrentPage] = useState(1); -const DirectSale = ({ UomData = [], TaxData = [], ProductTypeData = [], ProdCatData = [], ProdSubCatData = [], SupplierData = [], activeTab = null }) => { + const CompId = getSession('CompId'); + const BranchId = getSession('BranchId'); + const AppId = getSession('AppId'); + const UserId = getSession('UserId'); - const formRef = useRef(); - const tableRef = useRef(); - const searchInputRef = useRef(); - const dispatch = useDispatch(); - const [messageType, setMessageType] = useState(null); - const [messageData, setMessageData] = useState(null); - const [currentPage, setCurrentPage] = useState(1); + const [dataSource, setDataSource] = useState([]); + const [editingKey, setEditingKey] = useState(null); - const CompId = getSession('CompId'); - const BranchId = getSession('BranchId'); - const AppId = getSession('AppId'); - const UserId = getSession('UserId'); + const [copies, setCopies] = useState(null); + const [dropdownValue, setDropdownValue] = useState(null); + const [multiProduct, setMultiProduct] = useState(false); + const [printReady, setPrintReady] = useState(false); + const [printProductName, setPrintProductName] = useState(false); + const [productShortCodes, setAllProductShortCodes] = useState([]); + const [searchText, setSearchText] = useState(''); + console.log(searchText, 'searchText'); + const [stickerPrintModalOpen, setStickerPrintModalOpen] = useState(false); + const [barcodeTemplateDetails, setBarcodeTemplateDetails] = useState([]); + const [filteredProducts, setFilteredProducts] = useState([]); + const [labelPrintData, setLabelPrintData] = useState(null); + const [prodId, setProdId] = useState(null); + const [nickName, setNickName] = useState(null); + const [crossData, setCrossData] = useState(null); + const [triggerState, setTriggerState] = useState(1); + const [templateOptions, setTemplateOptions] = useState({ + mrp: false, + barcode: false, + color: false, + eDate: false, + mDate: false, + sellingPrice: false, + productName: false, + value: '', + secondValue: '', + qrcode: false, + codeType: '', + }); - const [dataSource, setDataSource] = useState([]); - const [editingKey, setEditingKey] = useState(null); + console.log(searchText != null && searchText != '', 'filteredProducts'); - const [copies, setCopies] = useState(null); - const [dropdownValue, setDropdownValue] = useState(null); - const [multiProduct, setMultiProduct] = useState(false); - const [printReady, setPrintReady] = useState(false); - const [printProductName, setPrintProductName] = useState(false); - const [productShortCodes, setAllProductShortCodes] = useState([]); - const [searchText, setSearchText] = useState(''); - console.log(searchText, "searchText") - const [stickerPrintModalOpen, setStickerPrintModalOpen] = useState(false); - const [barcodeTemplateDetails, setBarcodeTemplateDetails] = useState([]); - const [filteredProducts, setFilteredProducts] = useState([]); - const [labelPrintData, setLabelPrintData] = useState(null); - const [prodId, setProdId] = useState(null); - const [nickName, setNickName] = useState(null); - const [crossData, setCrossData] = useState(null); - const [triggerState, setTriggerState] = useState(1); - const [templateOptions, setTemplateOptions] = useState({ - mrp: false, - barcode: false, - color: false, - eDate: false, - mDate: false, - sellingPrice: false, - productName: false, - value: '', - secondValue: '', - qrcode: false, - codeType: '', + const { qrBase64, barcodeBase64 } = useBarcodeGenerator(prodId); + + const handleAdd = () => { + setDataSource([ + { + key: dataSource.length + 1, + productName: '', + shortCode: '', + sellingPrice: '', + uom: null, + tax: null, + prodId: null, + size: null, + uomName: null, + activeStatus: 'A', + }, + ...dataSource, + ]); + }; + + const handleDelete = async (record) => { + if (record?.prodId) { + if (searchText != null && searchText !== '') { + setSearchText(''); + setCurrentPage(1); + if (searchInputRef.current) { + searchInputRef.current.value = ''; + } + } + const deleteData = { + ProdId: record.prodId, + ActiveStatus: record.activeStatus === 'A' ? 'D' : 'A', + UpdatedBy: UserId, + }; + const response = await dispatch(deleteProductData(deleteData))?.unwrap(); + if (response?.data?.statusCode === 1) { + setMessageData( + record.activeStatus === 'A' + ? 'Product De-Activated Successfully' + : 'Product Activated Successfully' + ); + setMessageType('success'); + await fetchDirectSaleProducts(); + } else { + setMessageData(response?.data?.response || 'Failed to update status'); + setMessageType('error'); + } + return; + } else { + // const { key } = record; + // setDataSource(dataSource.filter(item => item.key !== key)); + setMessageData('Atleast one empty row should be in table.'); + setMessageType('warning'); + } + }; + + const handleChange = useCallback( + (key, field, value) => { + if (searchText) { + setFilteredProducts((prev) => + prev.map((item) => + item.key === key ? { ...item, [field]: value } : item + ) + ); + } else { + setDataSource((prev) => + prev.map((item) => + item.key === key ? { ...item, [field]: value } : item + ) + ); + } + }, + [searchText] + ); + + const handleSave = async (record) => { + if ( + !record.productName || + !record.sellingPrice || + !record.uom || + !record.tax || + !record?.shortCode + ) { + setMessageData('Please fill all the required fields!'); + setMessageType('warning'); + return; + } + + const exists = isShortCodeDuplicate(record?.shortCode, record?.prodId); + + if (exists) { + setMessageData('Short code already exists for another product'); + setMessageType('error'); + return; + } + + const postData = { + ProdName: record.productName, + Size: '1', + UOM: record.uom, + MRP: record.sellingPrice, + SellPrice: record.sellingPrice, + TaxId: record.tax, + CompId: CompId, + BranchId: BranchId, + AppId: AppId, + ProdType: ProductTypeData?.find((item) => item.ConfigName === 'Product') + ?.ConfigId, + ProdCat: ProdCatData?.find((item) => item.ConfigName === 'General') + ?.ConfigId, + ProdSubCat: ProdSubCatData?.find((item) => item.ConfigName === 'General') + ?.ConfigId, + QtyBasedPrice: 'N', + ProdQtywisePriceDetails: [], + StockAvailable: 'N', + TokenAvailable: 'N', + InwardDate: new Date().toJSON(), + SuppId: SupplierData?.find( + (item) => item.SuppName?.toLowerCase() === 'self' + )?.SuppId, + AutoGenerateQr: 'N', + QRCode: null, + CreatedBy: UserId, + ProdLogo: '', + Cess: 0, + ProdShortCode: record?.shortCode, + }; + + try { + if (record?.prodId) { + console.log('Updating Product'); + } else { + const response = await dispatch(postProductData(postData)).unwrap(); + if (response?.data?.statusCode === 1) { + const prodId = response?.data?.ProductDetails?.[0]?.ProdId; + const size = response?.data?.ProductDetails?.[0]?.Size; + const uomName = response?.data?.ProductDetails?.[0]?.UomName; + const totalProducts = response?.data?.ProductDetails?.[0]?.TotalCount; + setSearchText((currentSearchText) => { + if (currentSearchText != null && currentSearchText !== '') { + setCurrentPage(1); + setTriggerState((prev) => prev + 1); + if (searchInputRef.current) { + searchInputRef.current.value = ''; + } + return ''; + } else { + setDataSource((prev) => + prev.map((item) => + item.key === record.key + ? { ...item, prodId, size, uomName, totalProducts } + : { ...item, totalProducts } + ) + ); + } + return currentSearchText; + }); + setMessageData('Product saved successfully!'); + setMessageType('success'); + return; + } + } + } catch (error) { + console.error('Error saving product:', error); + } + }; + + const handlePrint = async (record) => { + const exists = isShortCodeDuplicate(record?.shortCode, record?.prodId); + if (exists) { + setMessageData( + 'Short code already exists for another product. Cannot print.' + ); + setMessageType('error'); + return; + } + setStickerPrintModalOpen(true); + setLabelPrintData({ + ...record, + MRP: record?.sellingPrice || 0, + SellPrice: record?.sellingPrice || 0, }); + setProdId(record?.shortCode + '' + record?.sellingPrice); + }; - console.log((searchText != null && searchText != ''), "filteredProducts") + const columns = useMemo( + () => [ + { + title: 'SL.No', + width: 50, + align: 'center', + render: (_, __, index) => (currentPage - 1) * 10 + index + 1, + }, + { + title: () => ( +
+ Product Name + + + +
+ ), + dataIndex: 'productName', + width: 150, + render: (text, record) => + record.prodId && editingKey !== record.key ? ( +
{text}
+ ) : ( + + handleChange(record.key, 'productName', e.target.value) + } + placeholder="Enter product name" + /> + ), + }, + { + title: () => ( +
+ Short Code + + + +
+ ), + dataIndex: 'shortCode', + width: 100, + render: (text, record) => + record.prodId && editingKey !== record.key ? ( +
{text}
+ ) : ( + { + const originalValue = e.target.value; + const hasNonAlpha = /[^a-zA-Z]/.test(originalValue); + if (hasNonAlpha) { + setMessageData('Enter Alphabet Characters only'); + setMessageType('warning'); + } + }} + onChange={(e) => { + const value = e.target.value + .replace(/[^a-zA-Z]/g, '') + .toUpperCase(); + const exists = isShortCodeDuplicate(value, record?.prodId); + if (exists && value) { + setMessageData( + 'Short code already exists for another product' + ); + setMessageType('error'); + } + handleChange(record.key, 'shortCode', value); + }} + placeholder="Short Code" + /> + ), + }, + { + title: () => ( +
+ Selling Price + + + +
+ ), + dataIndex: 'sellingPrice', + width: 120, + render: (text, record) => + record.prodId && editingKey !== record.key ? ( +
{text}
+ ) : ( + { + const value = e.target.value.replace(/[^0-9.]/g, ''); + const parts = value.split('.'); + const formatted = + parts.length > 2 + ? `${parts[0]}.${parts.slice(1).join('')}` + : value; + handleChange(record.key, 'sellingPrice', formatted); + }} + placeholder="0.00" + /> + ), + }, + { + title: () => ( +
+ UOM + + + +
+ ), + dataIndex: 'uom', + width: 60, + render: (text, record) => + record.prodId && editingKey !== record.key ? ( +
+ {UomData?.find((item) => item.ConfigId === text)?.ConfigName || + '-'} +
+ ) : ( + handleChange(record.key, 'tax', value)} + placeholder="Tax" + style={{ width: '100%' }} + options={TaxData?.map((item) => ({ + value: item.TaxId, + label: `${item.TaxIdName} - ${item.TaxPercentage}%`, + }))} + /> + ); + }, + }, + { + title: 'Save / Print', + width: 90, + align: 'center', + render: (_, record) => { + const existingProduct = record?.prodId; - const handleAdd = () => { - setDataSource([{ - key: dataSource.length + 1, + return ( +
+ {!existingProduct && ( + + )} + {existingProduct && ( + + )} +
+ ); + }, + }, + { + title: 'Action', + width: 60, + align: 'center', + render: (_, record) => { + if (record?.activeStatus === 'A') { + return ( + handleDelete(record)} + style={{ color: 'red', cursor: 'pointer', fontSize: '18px' }} + /> + ); + } else { + return ( + handleDelete(record)} + /> + ); + } + }, + }, + ], + [searchText, editingKey, productShortCodes, UomData, TaxData] + ); + + useEffect(() => { + if (activeTab === 'directSale' && AppId && CompId && BranchId) { + fetchDirectSaleProducts(); + fetchAllProductShortCodes(); + } + }, [activeTab, AppId, BranchId, CompId, currentPage, triggerState]); + + useEffect(() => { + if (dataSource.every((row) => row.prodId)) { + handleAdd(); + } + }, [dataSource]); + + useEffect(() => { + const timer = setTimeout(() => { + if (searchText) { + fetchSearchedProducts(); + } else { + setFilteredProducts([ + { + key: 1, productName: '', shortCode: '', sellingPrice: '', @@ -78,834 +552,526 @@ const DirectSale = ({ UomData = [], TaxData = [], ProductTypeData = [], ProdCatD prodId: null, size: null, uomName: null, - activeStatus: 'A' - }, ...dataSource]); + activeStatus: 'A', + }, + ]); + } + }, 500); + + return () => clearTimeout(timer); + }, [searchText, AppId, BranchId, CompId]); + + useEffect(() => { + const handleClickOutside = (event) => { + if ( + tableRef.current && + !tableRef.current.contains(event.target) && + !event.target.closest('.ant-select-dropdown') + ) { + setEditingKey(null); + } }; + document.addEventListener('mousedown', handleClickOutside); + return () => document.removeEventListener('mousedown', handleClickOutside); + }, []); - const handleDelete = async (record) => { - if (record?.prodId) { - if (searchText != null && searchText !== '') { - setSearchText('') - setCurrentPage(1); - if (searchInputRef.current) { - searchInputRef.current.value = ''; - } - } - const deleteData = { - ProdId: record.prodId, - ActiveStatus: record.activeStatus === 'A' ? 'D' : 'A', - UpdatedBy: UserId, - }; - const response = await dispatch(deleteProductData(deleteData))?.unwrap(); - if (response?.data?.statusCode === 1) { - setMessageData(record.activeStatus === 'A' ? 'Product De-Activated Successfully' : 'Product Activated Successfully'); - setMessageType('success'); - await fetchDirectSaleProducts(); - } else { - setMessageData(response?.data?.response || 'Failed to update status'); - setMessageType('error'); - } - return; - } else { - // const { key } = record; - // setDataSource(dataSource.filter(item => item.key !== key)); - setMessageData('Atleast one empty row should be in table.'); - setMessageType('warning'); - } - - }; - - const handleChange = useCallback((key, field, value) => { - if (searchText) { - setFilteredProducts(prev => - prev.map(item => - item.key === key ? { ...item, [field]: value } : item - ) - ); - } else { - setDataSource(prev => - prev.map(item => - item.key === key ? { ...item, [field]: value } : item - ) - ); - } - }, [searchText]); - - const handleSave = async (record) => { - - if (!record.productName || !record.sellingPrice || !record.uom || !record.tax || !record?.shortCode) { - setMessageData('Please fill all the required fields!'); - setMessageType('warning'); - return; - } - - const exists = isShortCodeDuplicate(record?.shortCode, record?.prodId); - - if (exists) { - setMessageData('Short code already exists for another product'); - setMessageType('error'); - return; - } - - const postData = { - ProdName: record.productName, - Size: '1', - UOM: record.uom, - MRP: record.sellingPrice, - SellPrice: record.sellingPrice, - TaxId: record.tax, - CompId: CompId, - BranchId: BranchId, - AppId: AppId, - ProdType: ProductTypeData?.find(item => item.ConfigName === 'Product')?.ConfigId, - ProdCat: ProdCatData?.find(item => item.ConfigName === 'General')?.ConfigId, - ProdSubCat: ProdSubCatData?.find(item => item.ConfigName === 'General')?.ConfigId, - QtyBasedPrice: 'N', - ProdQtywisePriceDetails: [], - StockAvailable: 'N', - TokenAvailable: 'N', - InwardDate: new Date().toJSON(), - SuppId: SupplierData?.find(item => item.SuppName?.toLowerCase() === 'self')?.SuppId, - AutoGenerateQr: 'N', - QRCode: null, - CreatedBy: UserId, - ProdLogo: '', - Cess: 0, - ProdShortCode: record?.shortCode - }; - - try { - if (record?.prodId) { - console.log('Updating Product') - } else { - const response = await dispatch(postProductData(postData)).unwrap(); - if (response?.data?.statusCode === 1) { - const prodId = response?.data?.ProductDetails?.[0]?.ProdId; - const size = response?.data?.ProductDetails?.[0]?.Size; - const uomName = response?.data?.ProductDetails?.[0]?.UomName; - const totalProducts = response?.data?.ProductDetails?.[0]?.TotalCount; - setSearchText(currentSearchText => { - if (currentSearchText != null && currentSearchText !== '') { - setCurrentPage(1); - setTriggerState(prev => prev + 1); - if (searchInputRef.current) { - searchInputRef.current.value = ''; - } - return ''; - } else { - setDataSource(prev => prev.map(item => - item.key === record.key ? { ...item, prodId, size, uomName, totalProducts } : { ...item, totalProducts } - )); - } - return currentSearchText; - }); - setMessageData('Product saved successfully!'); - setMessageType('success'); - return; - } - } - - } catch (error) { - console.error('Error saving product:', error); - } - }; - - const handlePrint = async (record) => { - const exists = isShortCodeDuplicate(record?.shortCode, record?.prodId); - if (exists) { - setMessageData('Short code already exists for another product. Cannot print.'); - setMessageType('error'); - return; - } - setStickerPrintModalOpen(true); - setLabelPrintData({ ...record, MRP: record?.sellingPrice || 0, SellPrice: record?.sellingPrice || 0 }); - setProdId(record?.shortCode + '' + record?.sellingPrice) + useEffect(() => { + if ( + activeTab === 'directSale' && + AppId && + CompId && + BranchId && + stickerPrintModalOpen + ) { + getBarcodeSessionData(); + fetchBarcodeTemplateDetails(); } + }, [activeTab, AppId, BranchId, CompId, stickerPrintModalOpen]); - const columns = useMemo(() => [ - { - title: 'SL.No', - width: 50, - align: 'center', - render: (_, __, index) => (currentPage - 1) * 10 + index + 1 - }, - { - title: () =>
Product Name - - - -
, - dataIndex: 'productName', - width: 150, - render: (text, record) => ( - record.prodId && editingKey !== record.key ? -
{text}
: - handleChange(record.key, 'productName', e.target.value)} - placeholder="Enter product name" - /> - ) - }, - { - title: () =>
Short Code - - - -
, - dataIndex: 'shortCode', - width: 100, - render: (text, record) => ( - record.prodId && editingKey !== record.key ? -
{text}
: - { - const originalValue = e.target.value; - const hasNonAlpha = /[^a-zA-Z]/.test(originalValue); - if (hasNonAlpha) { - setMessageData('Enter Alphabet Characters only'); - setMessageType('warning'); - } - }} - onChange={(e) => { - const value = e.target.value.replace(/[^a-zA-Z]/g, '').toUpperCase(); - const exists = isShortCodeDuplicate(value, record?.prodId); - if (exists && value) { - setMessageData('Short code already exists for another product'); - setMessageType('error'); - } - handleChange(record.key, 'shortCode', value); - }} - placeholder="Short Code" - /> - ) - }, - { - title: () =>
Selling Price - - - -
, - dataIndex: 'sellingPrice', - width: 120, - render: (text, record) => ( - record.prodId && editingKey !== record.key ? -
{text}
: - { - const value = e.target.value.replace(/[^0-9.]/g, ''); - const parts = value.split('.'); - const formatted = parts.length > 2 ? `${parts[0]}.${parts.slice(1).join('')}` : value; - handleChange(record.key, 'sellingPrice', formatted); - }} - placeholder="0.00" - /> - ) - }, - { - title: () =>
UOM - - - -
, - dataIndex: 'uom', - width: 60, - render: (text, record) => ( - record.prodId && editingKey !== record.key ? -
{UomData?.find(item => item.ConfigId === text)?.ConfigName || '-'}
: - handleChange(record.key, 'tax', value)} - placeholder="Tax" - style={{ width: '100%' }} - options={TaxData?.map(item => ({ - value: item.TaxId, - label: `${item.TaxIdName} - ${item.TaxPercentage}%` - }))} - /> - ); - } - }, - { - title: 'Save / Print', - width: 90, - align: 'center', - render: (_, record) => { - const existingProduct = record?.prodId; - - return ( -
- {!existingProduct && } - {existingProduct && } -
- ); - } - }, - { - title: 'Action', - width: 60, - align: "center", - render: (_, record) => { - if (record?.activeStatus === 'A') { - return handleDelete(record)} - style={{ color: 'red', cursor: 'pointer', fontSize: '18px' }} - /> - } else { - return handleDelete(record)} - /> - } - - } - } - ], [ - searchText, - editingKey, - productShortCodes, - UomData, - TaxData - ]); - - useEffect(() => { - if (activeTab === 'directSale' && AppId && CompId && BranchId) { - fetchDirectSaleProducts(); - fetchAllProductShortCodes(); - } - }, [activeTab, AppId, BranchId, CompId, currentPage, triggerState]); - - useEffect(() => { - if (dataSource.every(row => row.prodId)) { - handleAdd(); - } - }, [dataSource]); - - useEffect(() => { - const timer = setTimeout(() => { - if (searchText) { - fetchSearchedProducts(); - } else { - setFilteredProducts([{ - key: 1, - productName: '', - shortCode: '', - sellingPrice: '', - uom: null, - tax: null, - prodId: null, - size: null, - uomName: null, - activeStatus: 'A' - }]); - } - }, 500); - - return () => clearTimeout(timer); - }, [searchText, AppId, BranchId, CompId]); - - useEffect(() => { - const handleClickOutside = (event) => { - if (tableRef.current && !tableRef.current.contains(event.target) && !event.target.closest('.ant-select-dropdown')) { - setEditingKey(null); - } - }; - document.addEventListener('mousedown', handleClickOutside); - return () => document.removeEventListener('mousedown', handleClickOutside); - }, []); - - useEffect(() => { - if (activeTab === 'directSale' && AppId && CompId && BranchId && stickerPrintModalOpen) { - getBarcodeSessionData(); - fetchBarcodeTemplateDetails(); - } - }, [activeTab, AppId, BranchId, CompId, stickerPrintModalOpen]); - - const fetchSearchedProducts = async () => { - try { - const data = { - AppId: AppId, - CompId: CompId, - BranchId: BranchId, - prodName: searchText - } - const response = await dispatch(getDirectSaleSearchedProduct(data))?.unwrap(); - if (response?.data?.data?.length > 0 && response?.data?.statusCode === 1) { - const products = response?.data?.data?.map((item, index) => ({ - key: index + 1, - productName: item.ProdName, - shortCode: item.ProdShortCode, - sellingPrice: item.SellPrice, - uom: item.UOM, - tax: item.TaxId, - prodId: item.ProdId, - activeStatus: item?.ActiveStatus, - size: item.Size || 1, - uomName: item.UomName || 'PCS', - totalProducts: item?.TotalCount - })) - setFilteredProducts([{ - key: products.length + 1, - productName: '', - shortCode: '', - sellingPrice: '', - uom: null, - tax: null, - prodId: null, - size: null, - uomName: null, - activeStatus: 'A' - }, ...products]); - } else { - setFilteredProducts([{ - key: 1, - productName: '', - shortCode: '', - sellingPrice: '', - uom: null, - tax: null, - prodId: null, - size: null, - uomName: null, - activeStatus: 'A' - }]); - } - } catch (error) { - console.error(error?.message) - } - + const fetchSearchedProducts = async () => { + try { + const data = { + AppId: AppId, + CompId: CompId, + BranchId: BranchId, + prodName: searchText, + }; + const response = await dispatch( + getDirectSaleSearchedProduct(data) + )?.unwrap(); + if ( + response?.data?.data?.length > 0 && + response?.data?.statusCode === 1 + ) { + const products = response?.data?.data?.map((item, index) => ({ + key: index + 1, + productName: item.ProdName, + shortCode: item.ProdShortCode, + sellingPrice: item.SellPrice, + uom: item.UOM, + tax: item.TaxId, + prodId: item.ProdId, + activeStatus: item?.ActiveStatus, + size: item.Size || 1, + uomName: item.UomName || 'PCS', + totalProducts: item?.TotalCount, + })); + setFilteredProducts([ + { + key: products.length + 1, + productName: '', + shortCode: '', + sellingPrice: '', + uom: null, + tax: null, + prodId: null, + size: null, + uomName: null, + activeStatus: 'A', + }, + ...products, + ]); + } else { + setFilteredProducts([ + { + key: 1, + productName: '', + shortCode: '', + sellingPrice: '', + uom: null, + tax: null, + prodId: null, + size: null, + uomName: null, + activeStatus: 'A', + }, + ]); + } + } catch (error) { + console.error(error?.message); } + }; - const isShortCodeDuplicate = useCallback((code, prodId) => { - return productShortCodes.some( - item => - item.ProdShortCode.toUpperCase() === code.toUpperCase() && - item.ProdId !== prodId + const isShortCodeDuplicate = useCallback( + (code, prodId) => { + return productShortCodes.some( + (item) => + item.ProdShortCode.toUpperCase() === code.toUpperCase() && + item.ProdId !== prodId + ); + }, + [productShortCodes] + ); + + const fetchBarcodeTemplateDetails = async () => { + const response = await dispatch( + getBarcodeTemplate({ compId: CompId, appId: AppId, branchId: BranchId }) + ).unwrap(); + if (response?.data?.statusCode === 1 && response?.data?.data?.length > 0) { + const { TemplateDetails } = response?.data?.data?.[0]; + setBarcodeTemplateDetails(TemplateDetails); + } else { + setBarcodeTemplateDetails([]); + } + }; + + const getBarcodeSessionData = async () => { + try { + let response = await dispatch(getBarcodeSessionsIDs()).unwrap(); + if ( + response?.data?.statusCode === 1 && + response?.data?.data?.length > 0 + ) { + setCrossData( + response?.data?.data?.filter( + (item) => !item.ConfigName?.includes('100X13 (55MM Printable Gold)') + ) || [] ); - }, [productShortCodes]); - - const fetchBarcodeTemplateDetails = async () => { - const response = await dispatch( - getBarcodeTemplate({ compId: CompId, appId: AppId, branchId: BranchId }) - ).unwrap(); - if (response?.data?.statusCode === 1 && response?.data?.data?.length > 0) { - const { TemplateDetails } = response?.data?.data?.[0]; - setBarcodeTemplateDetails(TemplateDetails); - } else { - setBarcodeTemplateDetails([]); - } - }; - - const getBarcodeSessionData = async () => { - try { - let response = await dispatch(getBarcodeSessionsIDs()).unwrap(); - if (response?.data?.statusCode === 1 && response?.data?.data?.length > 0) { - setCrossData( - response?.data?.data?.filter( - (item) => !item.ConfigName?.includes('100X13 (55MM Printable Gold)') - ) || [] - ); - } else { - setCrossData([]); - } - } catch (error) { - console.error('Error fetching barcode session data:', error); - } - }; - - const fetchDirectSaleProducts = async () => { - try { - const data = { - AppId: AppId, - CompId: CompId, - BranchId: BranchId, - page: currentPage - } - - const response = await dispatch(getDirectSaleProducts(data))?.unwrap(); - if (response?.data?.statusCode === 1 && response?.data?.data?.length > 0) { - const products = response?.data?.data?.map((item, index) => ({ - key: index + 1, - productName: item.ProdName, - shortCode: item.ProdShortCode, - sellingPrice: item.SellPrice, - uom: item.UOM, - tax: item.TaxId, - prodId: item.ProdId, - activeStatus: item?.ActiveStatus, - size: item.Size || 1, - uomName: item.UomName || 'PCS', - totalProducts: item?.TotalCount - })); - setDataSource([{ - key: products.length + 1, - productName: '', - shortCode: '', - sellingPrice: '', - uom: null, - tax: null, - prodId: null, - size: null, - uomName: null, - activeStatus: 'A' - }, ...products]); - } else { - setDataSource([]) - } - - } catch (error) { - console.error('Error fetching direct sale products:', error); - } + } else { + setCrossData([]); + } + } catch (error) { + console.error('Error fetching barcode session data:', error); } + }; - const fetchAllProductShortCodes = async () => { - try { - const data = { - AppId: AppId, - CompId: CompId, - BranchId: BranchId, - } + const fetchDirectSaleProducts = async () => { + try { + const data = { + AppId: AppId, + CompId: CompId, + BranchId: BranchId, + page: currentPage, + }; - const response = await dispatch(getAllProductShortCodes(data))?.unwrap(); - if (response?.data?.statusCode === 1 && response?.data?.data?.length > 0) { - setAllProductShortCodes(response?.data?.data); - } else { - setAllProductShortCodes([]); - } - - console.log(response); - - } catch (error) { - console.error('Error fetching product short codes:', error); - } + const response = await dispatch(getDirectSaleProducts(data))?.unwrap(); + if ( + response?.data?.statusCode === 1 && + response?.data?.data?.length > 0 + ) { + const products = response?.data?.data?.map((item, index) => ({ + key: index + 1, + productName: item.ProdName, + shortCode: item.ProdShortCode, + sellingPrice: item.SellPrice, + uom: item.UOM, + tax: item.TaxId, + prodId: item.ProdId, + activeStatus: item?.ActiveStatus, + size: item.Size || 1, + uomName: item.UomName || 'PCS', + totalProducts: item?.TotalCount, + })); + setDataSource([ + { + key: products.length + 1, + productName: '', + shortCode: '', + sellingPrice: '', + uom: null, + tax: null, + prodId: null, + size: null, + uomName: null, + activeStatus: 'A', + }, + ...products, + ]); + } else { + setDataSource([]); + } + } catch (error) { + console.error('Error fetching direct sale products:', error); } + }; - const handlePageChange = (current) => { - setCurrentPage(current); - }; + const fetchAllProductShortCodes = async () => { + try { + const data = { + AppId: AppId, + CompId: CompId, + BranchId: BranchId, + }; - const onFinish = async () => { - const template = barcodeTemplateDetails?.find( - (find) => find.SessionName === dropdownValue - ); - const templateAvailable = template === undefined ? false : true; + const response = await dispatch(getAllProductShortCodes(data))?.unwrap(); + if ( + response?.data?.statusCode === 1 && + response?.data?.data?.length > 0 + ) { + setAllProductShortCodes(response?.data?.data); + } else { + setAllProductShortCodes([]); + } - if (templateAvailable) { - const checkComponent = (name) => - template?.OptionDetails?.some((some) => some.OptionName === name); - const mrp = checkComponent('MRP'); - const barcode = checkComponent('Barcode'); - const color = checkComponent('Color'); - const eDate = checkComponent('E Date'); - const mDate = checkComponent('M Date'); - const sellingPrice = checkComponent('Selling Price'); - const productName = checkComponent('Product Name'); - const qrcode = checkComponent('Qrcode'); - const position = template.Position !== '' ? template.Position : ''; - const positionString = - template.PositionString !== '' ? template.PositionString : ''; + console.log(response); + } catch (error) { + console.error('Error fetching product short codes:', error); + } + }; - setTemplateOptions({ - mrp: mrp, - barcode: barcode, - color: color, - eDate: eDate, - mDate: mDate, - sellingPrice: sellingPrice, - productName: productName, - value: position, - secondValue: positionString, - qrcode: qrcode, - codeType: template?.CodeType, - }); - } + const handlePageChange = (current) => { + setCurrentPage(current); + }; - setPrintReady(true); - - setTimeout(async () => { - switch (dropdownValue) { - case '15X15 6cross': // COMPLETE - await printDiv( - templateAvailable ? 'label-15X156cross' : 'StickerPrints0', - style + getPageStyle(92) - ); - handleModalClose(); - break; - case '22X35 3cross': // Need to check - await printDiv( - templateAvailable ? '22X353cross' : 'StickerPrints1', - style + getPageStyle(105) - ); - handleModalClose(); - break; - case '25X25 4cross': // COMPLETE - await printDiv( - templateAvailable ? '25X254cross' : 'StickerPrints2', - style + getPageStyle(100) - ); - handleModalClose(); - break; - case '25X50 2cross': //Need to check - await printDiv( - templateAvailable ? '25X502cross' : 'StickerPrints3', - style + getPageStyle(100) - ); - handleModalClose(); - break; - case '50X30 Single': // COMPLETE - await printDiv( - templateAvailable ? '50X30Single' : 'StickerPrints4', - style - ); - handleModalClose(); - break; - case '50X25 Single': // COMPLETE - await printDiv( - templateAvailable ? '50X25Single' : 'StickerPrints5', - style - ); - handleModalClose(); - break; - case '100X13 (55MM Printable)': //Need to check - await printDiv( - templateAvailable ? '100X13(55MMPrintable)' : 'StickerPrints6', - style - ); - handleModalClose(); - break; - case '100X15 (70MM Printable)': // COMPLETE - await printDiv( - templateAvailable ? '100X15(70MMPrintable)' : 'StickerPrints7', - style - ); - handleModalClose(); - break; - case '100X150': // COMPLETE - await printDiv( - templateAvailable ? '100X150' : 'StickerPrints8', - style - ); - handleModalClose(); - setPrintReady(false); - break; - default: - alert('! Select correct cross '); - setPrintReady(false); - } - }, 100); - }; - - const CoresOnChange = (params) => { - setDropdownValue(params); - formRef.current?.setFieldsValue({ Cross: params }); - const template = barcodeTemplateDetails?.find( - (find) => find.SessionName === params - ); - const checkComponent = (name) => - template?.OptionDetails?.some((some) => some.OptionName === name); - const productName = checkComponent('Product Name'); - setPrintProductName(productName); - }; - - const CopiesOnChange = (params) => { - setCopies(params); - formRef.current?.setFieldsValue({ Copies: params }); - }; - - const handleModalClose = () => { - setCopies(null) - setDropdownValue('') - setStickerPrintModalOpen(false); - setLabelPrintData(null); - setNickName(null); - setProdId(null) - setMultiProduct(false); - formRef?.current?.resetFields(); - setPrintReady(false); - }; - - const imageTagBarcodeAndQR = useCallback( - (w = 'auto', fs = '6px', codeData = null) => { - const currentCode = codeData || prodId; - return ( - (templateOptions.barcode || templateOptions.qrcode) && ( - <> - Barcode - {templateOptions.codeType !== 'B' && ( -

- {currentCode} -

- )} - - ) - ); - }, - [templateOptions, multiProduct, barcodeBase64, qrBase64, prodId] + const onFinish = async () => { + const template = barcodeTemplateDetails?.find( + (find) => find.SessionName === dropdownValue ); + const templateAvailable = template === undefined ? false : true; - const onComplete = useCallback(() => { - setMessageType(null); - setMessageData(null); - }, []); + if (templateAvailable) { + const checkComponent = (name) => + template?.OptionDetails?.some((some) => some.OptionName === name); + const mrp = checkComponent('MRP'); + const barcode = checkComponent('Barcode'); + const color = checkComponent('Color'); + const eDate = checkComponent('E Date'); + const mDate = checkComponent('M Date'); + const sellingPrice = checkComponent('Selling Price'); + const productName = checkComponent('Product Name'); + const qrcode = checkComponent('Qrcode'); + const position = template.Position !== '' ? template.Position : ''; + const positionString = + template.PositionString !== '' ? template.PositionString : ''; - return ( -
- { + switch (dropdownValue) { + case '15X15 6cross': // COMPLETE + await printDiv( + templateAvailable ? 'label-15X156cross' : 'StickerPrints0', + style + getPageStyle(92) + ); + handleModalClose(); + break; + case '22X35 3cross': // Need to check + await printDiv( + templateAvailable ? '22X353cross' : 'StickerPrints1', + style + getPageStyle(105) + ); + handleModalClose(); + break; + case '25X25 4cross': // COMPLETE + await printDiv( + templateAvailable ? '25X254cross' : 'StickerPrints2', + style + getPageStyle(100) + ); + handleModalClose(); + break; + case '25X50 2cross': //Need to check + await printDiv( + templateAvailable ? '25X502cross' : 'StickerPrints3', + style + getPageStyle(100) + ); + handleModalClose(); + break; + case '50X30 Single': // COMPLETE + await printDiv( + templateAvailable ? '50X30Single' : 'StickerPrints4', + style + ); + handleModalClose(); + break; + case '50X25 Single': // COMPLETE + await printDiv( + templateAvailable ? '50X25Single' : 'StickerPrints5', + style + ); + handleModalClose(); + break; + case '100X13 (55MM Printable)': //Need to check + await printDiv( + templateAvailable ? '100X13(55MMPrintable)' : 'StickerPrints6', + style + ); + handleModalClose(); + break; + case '100X15 (70MM Printable)': // COMPLETE + await printDiv( + templateAvailable ? '100X15(70MMPrintable)' : 'StickerPrints7', + style + ); + handleModalClose(); + break; + case '100X150': // COMPLETE + await printDiv( + templateAvailable ? '100X150' : 'StickerPrints8', + style + ); + handleModalClose(); + setPrintReady(false); + break; + default: + alert('! Select correct cross '); + setPrintReady(false); + } + }, 100); + }; + + const CoresOnChange = (params) => { + setDropdownValue(params); + formRef.current?.setFieldsValue({ Cross: params }); + const template = barcodeTemplateDetails?.find( + (find) => find.SessionName === params + ); + const checkComponent = (name) => + template?.OptionDetails?.some((some) => some.OptionName === name); + const productName = checkComponent('Product Name'); + setPrintProductName(productName); + }; + + const CopiesOnChange = (params) => { + setCopies(params); + formRef.current?.setFieldsValue({ Copies: params }); + }; + + const handleModalClose = () => { + setCopies(null); + setDropdownValue(''); + setStickerPrintModalOpen(false); + setLabelPrintData(null); + setNickName(null); + setProdId(null); + setMultiProduct(false); + formRef?.current?.resetFields(); + setPrintReady(false); + }; + + const imageTagBarcodeAndQR = useCallback( + (w = 'auto', fs = '6px', codeData = null) => { + const currentCode = codeData || prodId; + return ( + (templateOptions.barcode || templateOptions.qrcode) && ( + <> + Barcode -
- { - setSearchText(e.target.value); - setCurrentPage(1) - }} - /> -
-
- Note: Click on a row to modify the product details -
-
- ({ - onClick: () => record.prodId && setEditingKey(record.key) - })} - ownPagination={true} - pagination={{ - current: currentPage, - onChange: handlePageChange, - total: (searchText != null && searchText != '') ? filteredProducts?.length : ((dataSource[dataSource.length - 1]?.totalProducts || 0) + 1), - pageSize: 11, - showSizeChanger: false, - hideOnSinglePage: true, - }} - bordered - /> -
- - {stickerPrintModalOpen && { }} - selectedRecords={null} - coresdata={crossData} - dropdownValue={dropdownValue} - CoresOnChange={CoresOnChange} - barcodeTemplateDetails={barcodeTemplateDetails} - detail={labelPrintData} - proName={labelPrintData?.productName} - nickName={nickName} - ProdId={labelPrintData?.shortCode + '' + labelPrintData?.sellingPrice} - size={labelPrintData?.size} - // valueStyleColumn={valueStyleColumn} - // secondValueStyle={secondValueStyle} - // valueStyleRow={valueStyleRow} - CopiesOnChange={CopiesOnChange} - printProductName={printProductName} - totalCopies={null} - setstockWiseQrcode={null} - setProductWiseQrcode={null} - setNickName={setNickName} - templateOptions={templateOptions} - />} - - {printReady && ( - - generateQRCodeCopy(null, code) - } - generateCodeImage={(code, codeType = 'Q') => generateCodeImage(code, codeType, null)} - imageTagBarcodeAndQR={imageTagBarcodeAndQR} - dropdownValue={dropdownValue} - barcodeTemplateDetails={barcodeTemplateDetails} - /> + {templateOptions.codeType !== 'B' && ( +

+ {currentCode} +

)} + + ) + ); + }, + [templateOptions, multiProduct, barcodeBase64, qrBase64, prodId] + ); + + const onComplete = useCallback(() => { + setMessageType(null); + setMessageData(null); + }, []); + + return ( + Loading ...}> +
+ +
+ { + setSearchText(e.target.value); + setCurrentPage(1); + }} + />
- ); +
+ Note: Click on a row to modify the product details +
+
+ ({ + onClick: () => record.prodId && setEditingKey(record.key), + })} + ownPagination={true} + pagination={{ + current: currentPage, + onChange: handlePageChange, + total: + searchText != null && searchText != '' + ? filteredProducts?.length + : (dataSource[dataSource.length - 1]?.totalProducts || 0) + 1, + pageSize: 11, + showSizeChanger: false, + hideOnSinglePage: true, + }} + bordered + /> +
+ + {stickerPrintModalOpen && ( + {}} + selectedRecords={null} + coresdata={crossData} + dropdownValue={dropdownValue} + CoresOnChange={CoresOnChange} + barcodeTemplateDetails={barcodeTemplateDetails} + detail={labelPrintData} + proName={labelPrintData?.productName} + nickName={nickName} + ProdId={ + labelPrintData?.shortCode + '' + labelPrintData?.sellingPrice + } + size={labelPrintData?.size} + // valueStyleColumn={valueStyleColumn} + // secondValueStyle={secondValueStyle} + // valueStyleRow={valueStyleRow} + CopiesOnChange={CopiesOnChange} + printProductName={printProductName} + totalCopies={null} + setstockWiseQrcode={null} + setProductWiseQrcode={null} + setNickName={setNickName} + templateOptions={templateOptions} + /> + )} + + {printReady && ( + generateQRCodeCopy(null, code)} + generateCodeImage={(code, codeType = 'Q') => + generateCodeImage(code, codeType, null) + } + imageTagBarcodeAndQR={imageTagBarcodeAndQR} + dropdownValue={dropdownValue} + barcodeTemplateDetails={barcodeTemplateDetails} + /> + )} +
+
+ ); }; -export default DirectSale; \ No newline at end of file +export default DirectSale; diff --git a/src/Pages/BookingScreen/LayoutSubCategoryFetcher.jsx b/src/Pages/BookingScreen/LayoutSubCategoryFetcher.jsx new file mode 100644 index 0000000..ca47f77 --- /dev/null +++ b/src/Pages/BookingScreen/LayoutSubCategoryFetcher.jsx @@ -0,0 +1,45 @@ +import { useEffect } from 'react'; +import { useSelector, useDispatch, shallowEqual } from 'react-redux'; +import { + getLayoutSubCategories, + GlobalProductCategorie, +} from '../../Features/BookingScreen/BookingData/BookingData'; +import { getTemplateData } from '../../Features/ThemeChange/ThemeChange'; +import { getSession } from '../../Services/Others'; + +const LayoutSubCategoryFetcher = () => { + const dispatch = useDispatch(); + + const ProdCat = useSelector(GlobalProductCategorie, shallowEqual); + const templateData = useSelector(getTemplateData, shallowEqual); + + const CompId = getSession('CompId'); + const BranchId = getSession('BranchId'); + const AppId = getSession('AppId'); + + useEffect(() => { + if (!ProdCat) return; + + const isCategory5 = templateData?.BookingCategory?.[0] === 'Category5'; + const isLayout2 = templateData?.BookingLayout?.[0] === 'Layout2'; + + if (isCategory5 && isLayout2) { + dispatch( + getLayoutSubCategories({ + CompId, + BranchId, + AppId, + ProdCat, + }) + ); + } + }, [ + ProdCat, + templateData?.BookingCategory?.[0], + templateData?.BookingLayout?.[0], + ]); + + return null; // this component renders nothing +}; + +export default LayoutSubCategoryFetcher; diff --git a/src/Pages/BookingScreen/Template/BSLayout1/BSLayout1.jsx b/src/Pages/BookingScreen/Template/BSLayout1/BSLayout1.jsx index 276b81b..09b10a3 100644 --- a/src/Pages/BookingScreen/Template/BSLayout1/BSLayout1.jsx +++ b/src/Pages/BookingScreen/Template/BSLayout1/BSLayout1.jsx @@ -1,7 +1,9 @@ -import React, { useCallback, useEffect, useState } from 'react'; +import React, { lazy, Suspense, useCallback, useEffect, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { Tooltip, Badge, Popconfirm, DatePicker } from 'antd'; +import dayjs from 'dayjs'; import moment from 'moment'; +import { Messages } from '../../../../Components/Notifications/Messages.jsx'; import { isMobile } from 'react-device-detect'; import BSNavbar1 from '../../Components/BSNavbar/BSNavbar1'; import BSNavbar2 from '../../Components/BSNavbar/BSNavbar2'; @@ -12,7 +14,6 @@ import BSBillingTable4 from '../../Components/BSBillingTables/BSBillingTable4/BS import BSBillingTable5 from '../../Components/BSBillingTables/BSBillingTable5/BSBillingTable5'; import BSBillingTable6 from '../../Components/BSBillingTables/BSBillingTable6/BSBTOverall6'; import BSBillingTable7 from '../../Components/BSBillingTables/BSBillingTable7/BSBillingTable7Overall.jsx'; -import { ArrowUpOutlined } from '@ant-design/icons'; import BSItemCard from '../../Components/BSItemCards/BSItemCard'; import CategoryHorizontal from '../../Components/BSCategories/BSCategoryHorizontal'; import SubCategoryVertical from '../../Components/BSSubCategories/BSSubCategoryVertical'; @@ -39,14 +40,12 @@ import { GlobalBtoBQuickProductTransfer, GlobalOtherSevices, } from '../../../../Features/BookingScreen/BookingData/BookingData.js'; +import { useDateStore } from '../../../../Features/BookingScreen/BookingData/DateStore.js'; import { getSession } from '../../../../Services/Others.js'; -import { Messages } from '../../../../Components/Notifications/Messages.jsx'; -import BSKioskCounterPayment from '../../Components/UtillComponents/BSKioskCounterPayment.jsx'; import { getKioskDatas, globalKioskSalesCount, } from '../../../../Features/Kiosk/kiosk.js'; -import SalesCountComponent from '../SalesCountComponent.jsx'; import PozoKioskIcon from '../../Components/UtillComponents/Pozo retail icons/PozoKioskIcon.jsx'; import { GLobalSadminUserPin, @@ -54,37 +53,61 @@ import { checkSession, ApplicationPreferences, } from '../../../../Features/BrachLogin/BranchLogin'; -import SAdminUserNotification from '../../Components/BookingFunctionality/SAdminUserNotification.jsx'; import { getBookingStatus, GlobalBookingStatus, } from '../../../../Features/Payment/PaymentReceivedRetail/PaymentReceivedRetail.js'; -import TooltipWrapper from '../../../../Components/Tooltip/Tooltip.jsx'; -import RetailBookingClosing from '../RetailBookingClose.jsx'; -import { PutBookingClose } from '../../../../Features/BookingScreen/RetailBookingClose.js'; -import BookingCloseIcon from '../../Components/UtillComponents/BookingCloseIcon.jsx'; -import ListOfSalesInvoices from '../../Components/BSBillingTables/ListofInvoices/ListOfSalesInvoices.jsx'; -import BSEwayBillicon from '../../Components/UtillComponents/BSEwayBillicon.jsx'; -import BSComboItemCard from '../../Components/BSItemCards/BSComboItemCard.jsx'; -import BranchTransferComponent from '../../Components/UtillComponents/BSQuickBranchToBranchTransferComponent.jsx'; -import BSExpireProductsList from '../../Components/UtillComponents/BSExpireProductsList.jsx'; - -import BSOtherServiceItemCard from '../../Components/BSItemCards/BSOtherServiceItemCard.jsx'; import BSOtherServicesHorizontalcat from '../../Components/BSCategories/BSOtherServicesHorizontalcat'; -import BSNavbar3 from '../../Components/BSNavbar/BSNavbar3.jsx'; -import SalesCountForStandard from '../SalesCountForStandard.jsx'; -import StandardTable from '../../Components/BSBillingTables/StandardTable/StandardTable.jsx'; -import { useDateStore } from '../../../../Features/BookingScreen/BookingData/DateStore.js'; -import dayjs from 'dayjs'; -import BsBookingitemCard from '../../Components/BSItemCards/BsBookingitemCard.jsx'; -import { CiShop } from 'react-icons/ci'; -import BranchName from '../BranchName.jsx'; -import ComboSalesBillTable from '../../Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx'; -import PlanExpireNotification from '../PlanExpireNotification.jsx'; +import { PutBookingClose } from '../../../../Features/BookingScreen/RetailBookingClose.js'; +import TooltipWrapper from '../../../../Components/Tooltip/Tooltip.jsx'; +import BookingCloseIcon from '../../Components/UtillComponents/BookingCloseIcon.jsx'; +import BSEwayBillicon from '../../Components/UtillComponents/BSEwayBillicon.jsx'; +import SAdminUserNotification from '../../Components/BookingFunctionality/SAdminUserNotification.jsx'; +// Jsx Files +const BSKioskCounterPayment = lazy( + () => import('../../Components/UtillComponents/BSKioskCounterPayment.jsx') +); +const RetailBookingClosing = lazy(() => import('../RetailBookingClose.jsx')); +const ListOfSalesInvoices = lazy( + () => + import('../../Components/BSBillingTables/ListofInvoices/ListOfSalesInvoices.jsx') +); +const BSComboItemCard = lazy( + () => import('../../Components/BSItemCards/BSComboItemCard.jsx') +); +const BranchTransferComponent = lazy( + () => + import('../../Components/UtillComponents/BSQuickBranchToBranchTransferComponent.jsx') +); +const BSExpireProductsList = lazy( + () => import('../../Components/UtillComponents/BSExpireProductsList.jsx') +); +const BSOtherServiceItemCard = lazy( + () => import('../../Components/BSItemCards/BSOtherServiceItemCard.jsx') +); +const BSNavbar3 = lazy(() => import('../../Components/BSNavbar/BSNavbar3.jsx')); +const SalesCountForStandard = lazy( + () => import('../SalesCountForStandard.jsx') +); +const StandardTable = lazy( + () => + import('../../Components/BSBillingTables/StandardTable/StandardTable.jsx') +); +const BsBookingitemCard = lazy( + () => import('../../Components/BSItemCards/BsBookingitemCard.jsx') +); +const ComboSalesBillTable = lazy( + () => + import('../../Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx') +); +const SalesCountComponent = lazy(() => import('../SalesCountComponent.jsx')); +const PlanExpireNotification = lazy( + () => import('../PlanExpireNotification.jsx') +); const BSLayout1 = () => { const dispatch = useDispatch(); - + const { selectedDate, setSelectedDate } = useDateStore(); const SessionData = useSelector(StoredSessionData); const AppId = SessionData?.AppId; @@ -132,7 +155,7 @@ const BSLayout1 = () => { const SelectedBillColor = useSelector(SelectedGlobalBillingColorDetail); const currentDateValue = moment().format('YYYY-MM-DD HH:mm:ss'); - + const [popOverOpen, setPopOverOpen] = useState(false); const appPreferences = useSelector(ApplicationPreferences); const salespagefields = appPreferences?.find( @@ -157,15 +180,16 @@ const BSLayout1 = () => { (i) => i.SettingIdName === 'DineIn' )?.[0]; let containerHeight = isMobile - ? AppExpDate?.RemainingDays <= 7 || AppExpDate?.PlanType?.toLowerCase() === 'extend' + ? AppExpDate?.RemainingDays <= 7 || + AppExpDate?.PlanType?.toLowerCase() === 'extend' ? '575px' : '595px' - : UserType != 'Super Admin' && - UserType != 'Super Admin User' && - AppExpDate?.RemainingDays <= 7 || AppExpDate?.PlanType?.toLowerCase() === 'extend' + : (UserType != 'Super Admin' && + UserType != 'Super Admin User' && + AppExpDate?.RemainingDays <= 7) || + AppExpDate?.PlanType?.toLowerCase() === 'extend' ? '96vh' : '99vh'; - useEffect(() => { if (AppId && CompId && BranchId && UserId) { @@ -224,8 +248,6 @@ const BSLayout1 = () => { // setBadgeCount(length); }; - - const onComplete = useCallback(() => { setMessageData(null); setMessageType(null); @@ -298,352 +320,360 @@ const BSLayout1 = () => { }; // BSLayout1Data?.BookingNavbar?.[1]?.some((item) => item?.OptionName === "AddCustomer") return ( - <> - - {UserType != 'Super Admin' && - UserType != 'Super Admin User' && - (AppExpDate?.RemainingDays <= 7 || AppExpDate === 'undefined' || AppExpDate?.PlanType?.toLowerCase() === 'extend') && ( - - )} -
-
- {BookingNavbar == 'Navbar1' && } - {BookingNavbar == 'Navbar2' && } - {BookingNavbar == 'Navbar3' && } -
+ Loading…
}> + {' '} + <> + + {UserType != 'Super Admin' && + UserType != 'Super Admin User' && + (AppExpDate?.RemainingDays <= 7 || + AppExpDate === 'undefined' || + AppExpDate?.PlanType?.toLowerCase() === 'extend') && ( + + )}
- {BookingNavbar != 'Navbar3' ? ( -
+
+ {BookingNavbar == 'Navbar1' && } + {BookingNavbar == 'Navbar2' && } + {BookingNavbar == 'Navbar3' && } +
+
+ {BookingNavbar != 'Navbar3' ? (
- {UserType !== 'Employee' && ( -
- {PricingAppPricingName?.[0]?.PricingName + - ' / ' + - PricingAppPricingName?.[0]?.Type} -
- )} - {AvailableDate && ( -
- setSelectedDate(date)} - /> -
- )} - {!OtherServicesglobal && ( - - )} - {SessionData?.FeatureAddonData?.FeatureDtls?.find( - (item) => - item?.FeatureAddonName?.toLowerCase() === 'kiosk sales' - ) && - !sportsAppPreference && ( +
+ {UserType !== 'Employee' && ( +
+ {PricingAppPricingName?.[0]?.PricingName + + ' / ' + + PricingAppPricingName?.[0]?.Type} +
+ )} + {AvailableDate && (
0 ? 'none' : 'auto', - opacity: OrderStatus > 0 ? 0.5 : 1, + padding: '3px 5px', + marginLeft: '1rem', }} > - {!OtherServicesglobal && ( - - - openModalKiosk()} - style={{ cursor: 'pointer', fontSize: '1.5rem' }} - className="iconsize" - /> - - - )} -
- )} - {!OtherServicesglobal && ( - - {' '} - - - )} - {Kioskopen && ( - - )} - {SAdminuserPin?.length > 0 && - UserType != 'Super Admin User' && ( -
- setSelectedDate(date)} />
)} - {!OtherServicesglobal && ( - <> -
- {CheckBookingStatus == 'Open' ? ( -
- - {' '} - - -
- ) : ( -
- - BookingOpenFun('Open')} - > - - - - - -
- )} -
-
- - {''} - - -
- - )} -
-
- ) : ( - - )} -
-
-
- {!OtherServicesglobal && ( - - )} - {OtherServicesglobal && ( - - )} -
- -
-
- {Comboglobal === false && !OtherServicesglobal && ( - )} + {SessionData?.FeatureAddonData?.FeatureDtls?.find( + (item) => + item?.FeatureAddonName?.toLowerCase() === 'kiosk sales' + ) && + !sportsAppPreference && ( +
0 ? 'none' : 'auto', + opacity: OrderStatus > 0 ? 0.5 : 1, + }} + > + {!OtherServicesglobal && ( + + + openModalKiosk()} + style={{ + cursor: 'pointer', + fontSize: '1.5rem', + }} + className="iconsize" + /> + + + )} +
+ )} + {!OtherServicesglobal && ( + + {' '} + + + )} + {Kioskopen && ( + + )} + {SAdminuserPin?.length > 0 && + UserType != 'Super Admin User' && ( +
+ +
+ )} + {!OtherServicesglobal && ( + <> +
+ {CheckBookingStatus == 'Open' ? ( +
+ + {' '} + + +
+ ) : ( +
+ + BookingOpenFun('Open')} + > + + + + + +
+ )} +
+
+ + {''} + + +
+ + )}
- +
+ ) : ( + + )} +
+
- {Comboglobal === false && - !OtherServicesglobal && - (AvailableDate ? ( - - ) : ( - - ))} - {Comboglobal === true && !OtherServicesglobal && ( - )} {OtherServicesglobal && ( - )}
+ +
+
+ {Comboglobal === false && !OtherServicesglobal && ( + + )} +
+ +
+ {Comboglobal === false && + !OtherServicesglobal && + (AvailableDate ? ( + + ) : ( + + ))} + {Comboglobal === true && !OtherServicesglobal && ( + + )} + {OtherServicesglobal && ( + + )} +
+
+
+
+ {action ? ( + + ) : ( + <> + {BSLayout1Data?.BookingBilling?.[0] == 'Billing1' && ( + + )} + {BSLayout1Data?.BookingBilling?.[0] == 'Billing2' && ( + + )} + {BSLayout1Data?.BookingBilling?.[0] == 'Billing3' && ( + + )} + {BSLayout1Data?.BookingBilling?.[0] == 'Billing4' && ( + + )} + {BSLayout1Data?.BookingBilling?.[0] == 'Billing5' && ( + + )} + {BSLayout1Data?.BookingBilling?.[0] == 'Billing6' && ( + + )} + {BSLayout1Data?.BookingBilling?.[0] == 'Billing7' && ( + + )} + {BookingBilling == 'Billing8' && } + {BSLayout1Data?.BookingBilling?.[0] == + 'StandardBilling' && ( +
+ +
+ )} + + )}
-
-
- {action ? ( - - ) : ( - <> - {BSLayout1Data?.BookingBilling?.[0] == 'Billing1' && ( - - )} - {BSLayout1Data?.BookingBilling?.[0] == 'Billing2' && ( - - )} - {BSLayout1Data?.BookingBilling?.[0] == 'Billing3' && ( - - )} - {BSLayout1Data?.BookingBilling?.[0] == 'Billing4' && ( - - )} - {BSLayout1Data?.BookingBilling?.[0] == 'Billing5' && ( - - )} - {BSLayout1Data?.BookingBilling?.[0] == 'Billing6' && ( - - )} - {BSLayout1Data?.BookingBilling?.[0] == 'Billing7' && ( - - )} - {BookingBilling == 'Billing8' && } - {BSLayout1Data?.BookingBilling?.[0] == 'StandardBilling' && ( -
- -
- )} - - )} - {/*
- -
*/}
-
- {BookingModalOpen && ( - - )} - {ListOfInvoices && ( - - )} - + {BookingModalOpen && ( + + )} + {ListOfInvoices && ( + + )} + + ); }; diff --git a/src/Pages/BookingScreen/Template/BSLayout2/BSLayout2.jsx b/src/Pages/BookingScreen/Template/BSLayout2/BSLayout2.jsx index f9d83f4..e243b61 100644 --- a/src/Pages/BookingScreen/Template/BSLayout2/BSLayout2.jsx +++ b/src/Pages/BookingScreen/Template/BSLayout2/BSLayout2.jsx @@ -110,6 +110,7 @@ const SalesCountForStandard = lazy( () => import('../SalesCountForStandard.jsx') ); import BsBookingitemCard from '../../Components/BSItemCards/BsBookingitemCard.jsx'; +import LayoutSubCategoryFetcher from '../../LayoutSubCategoryFetcher.jsx'; const ListOfSalesInvoices = lazy( () => import('../../Components/BSBillingTables/ListofInvoices/ListOfSalesInvoices.jsx') @@ -182,15 +183,17 @@ const BSLayout2 = () => { (i) => i.SettingIdName === 'DineIn' )?.[0]; let containerHeight = isMobile - ? AppExpDate?.RemainingDays <= 7 || AppExpDate?.PlanType?.toLowerCase() === 'extend' + ? AppExpDate?.RemainingDays <= 7 || + AppExpDate?.PlanType?.toLowerCase() === 'extend' ? '575px' : '' - : UserType != 'Super Admin' && - UserType != 'Super Admin User' && - AppExpDate?.RemainingDays <= 7 || AppExpDate?.PlanType?.toLowerCase() === 'extend' + : (UserType != 'Super Admin' && + UserType != 'Super Admin User' && + AppExpDate?.RemainingDays <= 7) || + AppExpDate?.PlanType?.toLowerCase() === 'extend' ? '96vh' : '99vh'; - + const [ListOfInvoices, setListOfInvoices] = useState(false); const appPreferences = useSelector(ApplicationPreferences); const salespagefields = appPreferences?.find( @@ -210,7 +213,6 @@ const BSLayout2 = () => { preference?.PreferredStatus == 'Y' ); - useEffect(() => { fetchAmount(); if ( @@ -226,7 +228,7 @@ const BSLayout2 = () => { fetchBookingStatus(); } }, [AppId, CompId, BranchId, UserId]); - + const fetchAmount = async () => { let data = { CompId: CompId, @@ -334,9 +336,11 @@ const BSLayout2 = () => {
{UserType != 'Super Admin' && UserType != 'Super Admin User' && - (AppExpDate?.RemainingDays <= 7 || AppExpDate === 'undefined' || AppExpDate?.PlanType?.toLowerCase() === 'extend') && ( + (AppExpDate?.RemainingDays <= 7 || + AppExpDate === 'undefined' || + AppExpDate?.PlanType?.toLowerCase() === 'extend') && ( Loading...
}> - + )}
{ /> )} + + ); }; diff --git a/src/Pages/BookingScreen/Template/BSLayout3/BSLayout3.jsx b/src/Pages/BookingScreen/Template/BSLayout3/BSLayout3.jsx index ec4f7e5..6a1abe8 100644 --- a/src/Pages/BookingScreen/Template/BSLayout3/BSLayout3.jsx +++ b/src/Pages/BookingScreen/Template/BSLayout3/BSLayout3.jsx @@ -1,10 +1,15 @@ -import React, { useEffect, useState, useCallback } from 'react'; +import React, { + useEffect, + useState, + useCallback, + lazy, + Suspense, + useMemo, +} from 'react'; import { useDispatch, useSelector } from 'react-redux'; import moment from 'moment'; import { Tooltip, Badge, Popconfirm } from 'antd'; import { isMobile } from 'react-device-detect'; -import BSNavbar1 from '../../Components/BSNavbar/BSNavbar1'; -import BSNavbar2 from '../../Components/BSNavbar/BSNavbar2'; import CategoryHorizontal from '../../Components/BSCategories/BSCategoryHorizontal'; import SubCategoryHorizontal from '../../Components/BSSubCategories/BSSubCategoryHorizontal'; import BSItemCard from '../../Components/BSItemCards/BSItemCard'; @@ -12,8 +17,8 @@ import BSBillingTable1 from '../../Components/BSBillingTables/BSBillingTable1/BS import BSBillingTable2 from '../../Components/BSBillingTables/BSBillingTable2/BSBillingTable2'; import BSBillingTable3 from '../../Components/BSBillingTables/BSBillingTable3/BSBillingTable3overall'; import BSBillingTable4 from '../../Components/BSBillingTables/BSBillingTable4/BSBillingTable4Full'; -import BSBillingTable5 from '../../Components/BSBillingTables/BSBillingTable5/BSBillingTable5'; import BSBillingTable6 from '../../Components/BSBillingTables/BSBillingTable6/BSBTOverall6'; +import BSBillingTable5 from '../../Components/BSBillingTables/BSBillingTable5/BSBillingTable5'; import BSBillingTable7 from '../../Components/BSBillingTables/BSBillingTable7/BSBillingTable7Overall.jsx'; import { dynamicComponentProps } from '../DynamicComponentProps.js'; import { @@ -26,13 +31,10 @@ import { SelectedGlobalSubCatgColorDetail, StoredSessionData, } from '../../../../Features/ThemeChange/ThemeChange'; -import { ArrowUpOutlined } from '@ant-design/icons'; -import { settingDataSelector } from '../../../../Features/PreferenceMaster/PreferenceMaster.js'; import { GlobalSalesDetailData, getSalesDetailData, GlobalCombosearch, - GlobalOrderCardDetails, PreferenceData, GlobalOrderStatus, GlobalAppExpDateData, @@ -40,46 +42,77 @@ import { GlobalOtherSevices, } from '../../../../Features/BookingScreen/BookingData/BookingData.js'; import { getSession } from '../../../../Services/Others.js'; -import BSKioskCounterPayment from '../../Components/UtillComponents/BSKioskCounterPayment.jsx'; +import { PutBookingClose } from '../../../../Features/BookingScreen/RetailBookingClose.js'; import { getKioskDatas, globalKioskSalesCount, } from '../../../../Features/Kiosk/kiosk.js'; -import PozoKioskIcon from '../../Components/UtillComponents/Pozo retail icons/PozoKioskIcon.jsx'; import { GLobalSadminUserPin, putSadminUserExit, checkSession, ApplicationPreferences, -} from '../../../../Features/BrachLogin/BranchLogin'; +} from '../../../../Features/BrachLogin/BranchLogin.js'; +// Icons +import PozoKioskIcon from '../../Components/UtillComponents/Pozo retail icons/PozoKioskIcon.jsx'; +import BookingCloseIcon from '../../Components/UtillComponents/BookingCloseIcon.jsx'; +import BSEwayBillicon from '../../Components/UtillComponents/BSEwayBillicon.jsx'; import { Messages } from '../../../../Components/Notifications/Messages.jsx'; import SAdminUserNotification from '../../Components/BookingFunctionality/SAdminUserNotification.jsx'; -import '../../../../Styles/BookingScreen/Template/BSLayout3/BSLayout3.scss'; -import SalesCountComponent from '../SalesCountComponent.jsx'; import { getBookingStatus, GlobalBookingStatus, } from '../../../../Features/Payment/PaymentReceivedRetail/PaymentReceivedRetail.js'; import TooltipWrapper from '../../../../Components/Tooltip/Tooltip.jsx'; import RetailBookingClosing from '../RetailBookingClose.jsx'; -import { PutBookingClose } from '../../../../Features/BookingScreen/RetailBookingClose.js'; -import BookingCloseIcon from '../../Components/UtillComponents/BookingCloseIcon.jsx'; -import ListOfSalesInvoices from '../../Components/BSBillingTables/ListofInvoices/ListOfSalesInvoices.jsx'; -import BSEwayBillicon from '../../Components/UtillComponents/BSEwayBillicon.jsx'; -import BSComboItemCard from '../../Components/BSItemCards/BSComboItemCard.jsx'; -import BranchTransferComponent from '../../Components/UtillComponents/BSQuickBranchToBranchTransferComponent.jsx'; -import BSExpireProductsList from '../../Components/UtillComponents/BSExpireProductsList.jsx'; +// Jsx Files +const SalesCountComponent = lazy(() => import('../SalesCountComponent.jsx')); +const BSKioskCounterPayment = lazy( + () => import('../../Components/UtillComponents/BSKioskCounterPayment.jsx') +); +const ListOfSalesInvoices = lazy( + () => + import('../../Components/BSBillingTables/ListofInvoices/ListOfSalesInvoices.jsx') +); +const BSComboItemCard = lazy( + () => import('../../Components/BSItemCards/BSComboItemCard.jsx') +); +const BranchTransferComponent = lazy( + () => + import('../../Components/UtillComponents/BSQuickBranchToBranchTransferComponent.jsx') +); +const BSExpireProductsList = lazy( + () => import('../../Components/UtillComponents/BSExpireProductsList.jsx') +); +const BSOtherServiceItemCard = lazy( + () => import('../../Components/BSItemCards/BSOtherServiceItemCard.jsx') +); +const BSOtherServicesHorizontalcat = lazy( + () => import('../../Components/BSCategories/BSOtherServicesHorizontalcat') +); +const BSNavbar3 = lazy(() => import('../../Components/BSNavbar/BSNavbar3.jsx')); +const SalesCountForStandard = lazy( + () => import('../SalesCountForStandard.jsx') +); +const StandardTable = lazy( + () => + import('../../Components/BSBillingTables/StandardTable/StandardTable.jsx') +); +const ComboSalesBillTable = lazy( + () => + import('../../Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx') +); +const PlanExpireNotification = lazy( + () => import('../PlanExpireNotification.jsx') +); +const BSNavbar1 = lazy(() => import('../../Components/BSNavbar/BSNavbar1')); +const BSNavbar2 = lazy(() => import('../../Components/BSNavbar/BSNavbar2')); +// Scss +import '../../../../Styles/BookingScreen/Template/BSLayout3/BSLayout3.scss'; + const subDirectory = import.meta.env.BASE_URL; const commonDirectory = import.meta.env.COMMON_BASE_URL; -import BSOtherServiceItemCard from '../../Components/BSItemCards/BSOtherServiceItemCard.jsx'; -import BSOtherServicesHorizontalcat from '../../Components/BSCategories/BSOtherServicesHorizontalcat'; -import BSNavbar3 from '../../Components/BSNavbar/BSNavbar3.jsx'; -import SalesCountForStandard from '../SalesCountForStandard.jsx'; -import StandardTable from '../../Components/BSBillingTables/StandardTable/StandardTable.jsx'; -import { CiShop } from 'react-icons/ci'; -import BranchName from '../BranchName.jsx'; -import ComboSalesBillTable from '../../Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx'; -import PlanExpireNotification from '../PlanExpireNotification.jsx'; + const BSLayout3 = () => { const dispatch = useDispatch(); const { action, selectedProducts } = useSelector( @@ -106,10 +139,12 @@ const BSLayout3 = () => { const BookingStatus = useSelector(GlobalBookingStatus); const appPreferences = useSelector(ApplicationPreferences); const commonModulePreference = appPreferences?.find( - (preference) => preference?.PreferredCatName === "Common Module" + (preference) => preference?.PreferredCatName === 'Common Module' )?.PreferenceCatDetails; const sportsAppPreference = commonModulePreference?.find( - (preference) => preference?.PreferredSubCatName === "SportsApp" && preference?.PreferredStatus == 'Y' + (preference) => + preference?.PreferredSubCatName === 'SportsApp' && + preference?.PreferredStatus == 'Y' ); const CheckBookingStatus = BookingStatus?.find((item) => item.ScreenType === 'Booking') @@ -124,10 +159,13 @@ const BSLayout3 = () => { const BookingSubCategory = BSLayout3Data?.BookingSubCategory; const BookingCard = BSLayout3Data?.BookingCard; const BookingBilling = BSLayout3Data?.BookingBilling?.[0]; - - const DineInAccess = SettingDataSelector?.[0]?.SettingDtlDetails.filter( - (i) => i.SettingIdName === 'DineIn' - )?.[0]; + const animations = ['example1', 'example2', 'example3']; + let ss = animations[count]; + const DineInAccess = useMemo(() => { + return SettingDataSelector?.[0]?.SettingDtlDetails.filter( + (i) => i.SettingIdName === 'DineIn' + )?.[0]; + }, [SettingDataSelector]); const [ListOfInvoices, setListOfInvoices] = useState(false); const AppId = SessionData?.AppId; const CompId = SessionData?.CompId; @@ -136,12 +174,14 @@ const BSLayout3 = () => { const UserType = SessionData?.UserType; const currentDateValue = moment().format('YYYY-MM-DD HH:mm:ss'); let containerHeight = isMobile - ? AppExpDate?.RemainingDays <= 7 || AppExpDate?.PlanType?.toLowerCase() === 'extend' + ? AppExpDate?.RemainingDays <= 7 || + AppExpDate?.PlanType?.toLowerCase() === 'extend' ? '576px' : '590px' - : UserType != 'Super Admin' && - UserType != 'Super Admin User' && - AppExpDate?.RemainingDays <= 7 || AppExpDate?.PlanType?.toLowerCase() === 'extend' + : (UserType != 'Super Admin' && + UserType != 'Super Admin User' && + AppExpDate?.RemainingDays <= 7) || + AppExpDate?.PlanType?.toLowerCase() === 'extend' ? '95vh' : '99vh'; const SAdminuserPin = useSelector(GLobalSadminUserPin); @@ -162,7 +202,6 @@ const BSLayout3 = () => { } }, [SessionData]); - const fetchKioskDatas = async () => { let data = { CompId: CompId, @@ -261,302 +300,330 @@ const BSLayout3 = () => { setListOfInvoices(false); }; return ( - <> - - {UserType != 'Super Admin' && - UserType != 'Super Admin User' && - (AppExpDate?.RemainingDays <= 7 || AppExpDate === 'undefined' || AppExpDate?.PlanType?.toLowerCase() === 'extend') && ( - - )} -
-
- {BookingNavbar == 'Navbar1' && } - {BookingNavbar == 'Navbar2' && } - {BookingNavbar == 'Navbar3' && } -
+ Suspense Loading...
}> + <> + + {UserType != 'Super Admin' && + UserType != 'Super Admin User' && + (AppExpDate?.RemainingDays <= 7 || + AppExpDate === 'undefined' || + AppExpDate?.PlanType?.toLowerCase() === 'extend') && ( + + )}
- {BookingNavbar != 'Navbar3' ? ( -
-
- {UserType !== 'Employee' && -
- {PricingAppPricingName?.[0]?.PricingName + - ' / ' + - PricingAppPricingName?.[0]?.Type} -
- } - {!OtherServicesglobal && } - {!OtherServicesglobal && SessionData?.FeatureAddonData?.FeatureDtls?.find( - (item) => - item?.FeatureAddonName?.toLowerCase() === 'kiosk sales' - ) && !sportsAppPreference && ( -
0 ? 'none' : 'auto', - opacity: OrderStatus > 0 ? 0.5 : 1, - }} - > - - {''} - - openModalKiosk()} - style={{ cursor: 'pointer', fontSize: '1.5rem' }} - className="iconsize" - /> - - -
- )} - {!OtherServicesglobal && ( - - {' '} - - - )} - {!OtherServicesglobal && Kioskopen && ( - - )} - {SAdminuserPin?.length > 0 && UserType != 'Super Admin User' && ( -
- -
- )} - - {!OtherServicesglobal && <> {CheckBookingStatus == 'Open' ? ( -
- - {' '} - - {/* */} - -
- ) : ( -
- - BookingOpenFun('Open')} - > - - - - - - -
- )} } - {!OtherServicesglobal && -
- - {''} - - -
} -
-
- ) : - - } +
+ {BookingNavbar == 'Navbar1' && } + {BookingNavbar == 'Navbar2' && } + {BookingNavbar == 'Navbar3' && } +
-
+ {BookingNavbar != 'Navbar3' ? (
- {!OtherServicesglobal && ( - - )} - {OtherServicesglobal && ( - - )} -
- -
- {!OtherServicesglobal && Comboglobal === false && ( - - )} -
- -
- {!OtherServicesglobal && Comboglobal === false && ( - - )} - {!OtherServicesglobal && Comboglobal === true && ( - - )} - {OtherServicesglobal && ( - - )} -
-
- -
- {action ? ( - - ) : ( - <> - {BSLayout3Data?.BookingBilling?.[0] == 'Billing1' && ( - - )} - {BSLayout3Data?.BookingBilling?.[0] == 'Billing2' && ( - - )} - {BSLayout3Data?.BookingBilling?.[0] == 'Billing3' && ( - - )} - {BSLayout3Data?.BookingBilling?.[0] == 'Billing4' && ( - - )} - {BSLayout3Data?.BookingBilling?.[0] == 'Billing5' && ( - - )} - {BSLayout3Data?.BookingBilling?.[0] == 'Billing6' && ( - - )} - {BSLayout3Data?.BookingBilling?.[0] == 'Billing7' && ( - - )} - {BookingBilling == 'Billing8' && } - {BSLayout3Data?.BookingBilling?.[0] == 'StandardBilling' && ( -
- +
+ {UserType !== 'Employee' && ( +
+ {PricingAppPricingName?.[0]?.PricingName + + ' / ' + + PricingAppPricingName?.[0]?.Type}
)} - - )} - {/*
- -
*/} + {!OtherServicesglobal && ( + + )} + {!OtherServicesglobal && + SessionData?.FeatureAddonData?.FeatureDtls?.find( + (item) => + item?.FeatureAddonName?.toLowerCase() === 'kiosk sales' + ) && + !sportsAppPreference && ( +
0 ? 'none' : 'auto', + opacity: OrderStatus > 0 ? 0.5 : 1, + }} + > + + {''} + + openModalKiosk()} + style={{ cursor: 'pointer', fontSize: '1.5rem' }} + className="iconsize" + /> + + +
+ )} + {!OtherServicesglobal && ( + + {' '} + + + )} + {!OtherServicesglobal && Kioskopen && ( + + )} + {SAdminuserPin?.length > 0 && + UserType != 'Super Admin User' && ( +
+ +
+ )} + + {!OtherServicesglobal && ( + <> + {' '} + {CheckBookingStatus == 'Open' ? ( +
+ + {' '} + + {/* */} + +
+ ) : ( +
+ + BookingOpenFun('Open')} + > + + + + + +
+ )}{' '} + + )} + {!OtherServicesglobal && ( +
+ + {''} + + +
+ )} +
+
+ ) : ( + <> + + + )} +
+
+
+ {!OtherServicesglobal && ( + + )} + {OtherServicesglobal && ( + + )} +
+ +
+ {!OtherServicesglobal && Comboglobal === false && ( + + )} +
+ +
+ {!OtherServicesglobal && Comboglobal === false && ( + + )} + {!OtherServicesglobal && Comboglobal === true && ( + + )} + {OtherServicesglobal && ( + + )} +
+
+ +
+ {action ? ( + + ) : ( + <> + {BSLayout3Data?.BookingBilling?.[0] == 'Billing1' && ( + + )} + {BSLayout3Data?.BookingBilling?.[0] == 'Billing2' && ( + + )} + {BSLayout3Data?.BookingBilling?.[0] == 'Billing3' && ( + + )} + {BSLayout3Data?.BookingBilling?.[0] == 'Billing4' && ( + + )} + {BSLayout3Data?.BookingBilling?.[0] == 'Billing5' && ( + + )} + {BSLayout3Data?.BookingBilling?.[0] == 'Billing6' && ( + + )} + {BSLayout3Data?.BookingBilling?.[0] == 'Billing7' && ( + + )} + {BookingBilling == 'Billing8' && } + {BSLayout3Data?.BookingBilling?.[0] == + 'StandardBilling' && ( +
+ +
+ )} + + )} +
-
- {BookingModalOpen && !OtherServicesglobal && ( - - )} - {ListOfInvoices && !OtherServicesglobal && ( - - )} - + {BookingModalOpen && !OtherServicesglobal && ( + + )} + {ListOfInvoices && !OtherServicesglobal && ( + + )} + + ); }; diff --git a/src/Pages/BookingScreen/Template/BSLayout4/BSLayout4.jsx b/src/Pages/BookingScreen/Template/BSLayout4/BSLayout4.jsx index 6311eac..be9bfed 100644 --- a/src/Pages/BookingScreen/Template/BSLayout4/BSLayout4.jsx +++ b/src/Pages/BookingScreen/Template/BSLayout4/BSLayout4.jsx @@ -1,21 +1,43 @@ -import React, { useCallback, useEffect, useState } from 'react'; +import {lazy, Suspense, useCallback, useEffect, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import moment from 'moment'; import { Tooltip, Badge, Popconfirm } from 'antd'; import { isMobile } from 'react-device-detect'; -import { ArrowUpOutlined } from '@ant-design/icons'; import BookingCloseIcon from '../../Components/UtillComponents/BookingCloseIcon.jsx'; -import BSNavbar1 from '../../Components/BSNavbar/BSNavbar1'; -import BSNavbar2 from '../../Components/BSNavbar/BSNavbar2'; -import CategoryVertical from '../../Components/BSCategories/BSCategoryVertical'; -import BSItemCard from '../../Components/BSItemCards/BSItemCard'; -import BSBillingTable1 from '../../Components/BSBillingTables/BSBillingTable1/BSBTOverall1'; -import BSBillingTable2 from '../../Components/BSBillingTables/BSBillingTable2/BSBillingTable2'; -import BSBillingTable3 from '../../Components/BSBillingTables/BSBillingTable3/BSBillingTable3overall'; -import BSBillingTable4 from '../../Components/BSBillingTables/BSBillingTable4/BSBillingTable4Full'; -import BSBillingTable5 from '../../Components/BSBillingTables/BSBillingTable5/BSBillingTable5'; -import BSBillingTable6 from '../../Components/BSBillingTables/BSBillingTable6/BSBTOverall6'; -import BSBillingTable7 from '../../Components/BSBillingTables/BSBillingTable7/BSBillingTable7Overall.jsx'; +const BSNavbar1 = lazy(() => import('../../Components/BSNavbar/BSNavbar1')); +const BSNavbar2 = lazy(() => import('../../Components/BSNavbar/BSNavbar2')); +const CategoryVertical = lazy( + () => import('../../Components/BSCategories/BSCategoryVertical') +); +const BSItemCard = lazy( + () => import('../../Components/BSItemCards/BSItemCard') +); +const BSBillingTable1 = lazy( + () => import('../../Components/BSBillingTables/BSBillingTable1/BSBTOverall1') +); +const BSBillingTable2 = lazy( + () => + import('../../Components/BSBillingTables/BSBillingTable2/BSBillingTable2') +); +const BSBillingTable3 = lazy( + () => + import('../../Components/BSBillingTables/BSBillingTable3/BSBillingTable3overall') +); +const BSBillingTable4 = lazy( + () => + import('../../Components/BSBillingTables/BSBillingTable4/BSBillingTable4Full') +); +const BSBillingTable5 = lazy( + () => + import('../../Components/BSBillingTables/BSBillingTable5/BSBillingTable5') +); +const BSBillingTable6 = lazy( + () => import('../../Components/BSBillingTables/BSBillingTable6/BSBTOverall6') +); +const BSBillingTable7 = lazy( + () => + import('../../Components/BSBillingTables/BSBillingTable7/BSBillingTable7Overall.jsx') +); import { dynamicComponentProps } from '../DynamicComponentProps.js'; import { getTemplateData, @@ -51,31 +73,66 @@ import { } from '../../../../Features/BrachLogin/BranchLogin'; import { Messages } from '../../../../Components/Notifications/Messages.jsx'; import SAdminUserNotification from '../../Components/BookingFunctionality/SAdminUserNotification.jsx'; -import '../../../../Styles/BookingScreen/Template/BSLayout4/BSLayout4.scss'; -import SalesCountComponent from '../SalesCountComponent.jsx'; +const SalesCountComponent = lazy(() => import('../SalesCountComponent.jsx')); import { getBookingStatus, GlobalBookingStatus, } from '../../../../Features/Payment/PaymentReceivedRetail/PaymentReceivedRetail.js'; import { PutBookingClose } from '../../../../Features/BookingScreen/RetailBookingClose.js'; import TooltipWrapper from '../../../../Components/Tooltip/Tooltip.jsx'; -import RetailBookingClosing from '../RetailBookingClose.jsx'; -import ListOfSalesInvoices from '../../Components/BSBillingTables/ListofInvoices/ListOfSalesInvoices.jsx'; -import BSEwayBillicon from '../../Components/UtillComponents/BSEwayBillicon.jsx'; -import BSComboItemCard from '../../Components/BSItemCards/BSComboItemCard.jsx'; -import BranchTransferComponent from '../../Components/UtillComponents/BSQuickBranchToBranchTransferComponent.jsx'; -import BSExpireProductsList from '../../Components/UtillComponents/BSExpireProductsList.jsx'; -import BSOtherServiceItemCard from '../../Components/BSItemCards/BSOtherServiceItemCard.jsx'; -import BSOtherServicesHorizontalcat from '../../Components/BSCategories/BSOtherServicesHorizontalcat'; -import BSOtherServicesVerticalcat from '../../Components/BSCategories/BSOtherServicesVerticalcat.jsx'; -import BSNavbar3 from '../../Components/BSNavbar/BSNavbar3.jsx'; -import SalesCountForStandard from '../SalesCountForStandard.jsx'; -import StandardTable from '../../Components/BSBillingTables/StandardTable/StandardTable.jsx'; -import { CiShop } from 'react-icons/ci'; -import BranchName from '../BranchName.jsx'; -import ComboSalesBillTable from '../../Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx'; -import PlanExpireNotification from '../PlanExpireNotification.jsx'; +const RetailBookingClosing = lazy(() => import('../RetailBookingClose.jsx')); +const ListOfSalesInvoices = lazy( + () => + import('../../Components/BSBillingTables/ListofInvoices/ListOfSalesInvoices.jsx') +); + +const BSEwayBillicon = lazy( + () => import('../../Components/UtillComponents/BSEwayBillicon.jsx') +); + +const BSComboItemCard = lazy( + () => import('../../Components/BSItemCards/BSComboItemCard.jsx') +); + +const BranchTransferComponent = lazy( + () => + import('../../Components/UtillComponents/BSQuickBranchToBranchTransferComponent.jsx') +); + +const BSExpireProductsList = lazy( + () => import('../../Components/UtillComponents/BSExpireProductsList.jsx') +); + +const BSOtherServiceItemCard = lazy( + () => import('../../Components/BSItemCards/BSOtherServiceItemCard.jsx') +); + +const BSOtherServicesVerticalcat = lazy( + () => import('../../Components/BSCategories/BSOtherServicesVerticalcat.jsx') +); + +const BSNavbar3 = lazy(() => import('../../Components/BSNavbar/BSNavbar3.jsx')); + +const SalesCountForStandard = lazy( + () => import('../SalesCountForStandard.jsx') +); + +const StandardTable = lazy( + () => + import('../../Components/BSBillingTables/StandardTable/StandardTable.jsx') +); + +const ComboSalesBillTable = lazy( + () => + import('../../Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx') +); +import PlanExpireNotification from '../PlanExpireNotification.jsx'; +// Scss +import '../../../../Styles/BookingScreen/Template/BSLayout4/BSLayout4.scss'; + +const subDirectory = import.meta.env.BASE_URL; +const commonDirectory = import.meta.env.COMMON_BASE_URL; const BSLayout4 = () => { const dispatch = useDispatch(); @@ -103,10 +160,12 @@ const BSLayout4 = () => { const SelectedBillColor = useSelector(SelectedGlobalBillingColorDetail); const appPreferences = useSelector(ApplicationPreferences); const commonModulePreference = appPreferences?.find( - (preference) => preference?.PreferredCatName === "Common Module" + (preference) => preference?.PreferredCatName === 'Common Module' )?.PreferenceCatDetails; const sportsAppPreference = commonModulePreference?.find( - (preference) => preference?.PreferredSubCatName === "SportsApp" && preference?.PreferredStatus == 'Y' + (preference) => + preference?.PreferredSubCatName === 'SportsApp' && + preference?.PreferredStatus == 'Y' ); // const [AppExpDate, setAppExpDate] = useState(0); const [Kioskopen, setKioskopen] = useState(false); @@ -130,12 +189,14 @@ const BSLayout4 = () => { const UserType = SessionData?.UserType; const currentDateValue = moment().format('YYYY-MM-DD HH:mm:ss'); let containerHeight = isMobile - ? AppExpDate?.RemainingDays <= 7 || AppExpDate?.PlanType?.toLowerCase() === 'extend' + ? AppExpDate?.RemainingDays <= 7 || + AppExpDate?.PlanType?.toLowerCase() === 'extend' ? '575px' : '590px' - : UserType != 'Super Admin' && - UserType != 'Super Admin User' && - AppExpDate?.RemainingDays <= 7 || AppExpDate?.PlanType?.toLowerCase() === 'extend' + : (UserType != 'Super Admin' && + UserType != 'Super Admin User' && + AppExpDate?.RemainingDays <= 7) || + AppExpDate?.PlanType?.toLowerCase() === 'extend' ? '96vh' : '99vh'; const [ListOfInvoices, setListOfInvoices] = useState(false); @@ -203,7 +264,6 @@ const BSLayout4 = () => { setKioskopen(false); }; - const handlePopOverOpen = () => { setPopOverOpen(!popOverOpen); }; @@ -257,103 +317,127 @@ const BSLayout4 = () => { setBookingModalOpen(false); }; return ( - <> - - {UserType != 'Super Admin' && - UserType != 'Super Admin User' && - (AppExpDate?.RemainingDays <= 7 || AppExpDate === 'undefined' || AppExpDate?.PlanType?.toLowerCase() === 'extend') && ( - - )} -
-
- {BookingNavbar == 'Navbar1' && } - {BookingNavbar == 'Navbar2' && } - {BookingNavbar == 'Navbar3' && } -
- {BookingNavbar != 'Navbar3' ? ( -
-
- {UserType !== 'Employee' && -
- {PricingAppPricingName?.[0]?.PricingName + - ' / ' + - PricingAppPricingName?.[0]?.Type} -
- } - {!OtherServicesglobal && } - {!OtherServicesglobal && SessionData?.FeatureAddonData?.FeatureDtls?.find( - (item) => item?.FeatureAddonName?.toLowerCase() === 'kiosk sales' - ) && !sportsAppPreference && ( -
0 ? 'none' : 'auto', - opacity: OrderStatus > 0 ? 0.5 : 1, - }} - > - - - openModalKiosk()} - style={{ cursor: 'pointer', fontSize: '1.5rem' }} - className="iconsize" - /> - - + Loading...
}> + <> + + {UserType != 'Super Admin' && + UserType != 'Super Admin User' && + (AppExpDate?.RemainingDays <= 7 || + AppExpDate === 'undefined' || + AppExpDate?.PlanType?.toLowerCase() === 'extend') && ( + + )} +
+
+ {BookingNavbar == 'Navbar1' && } + {BookingNavbar == 'Navbar2' && } + {BookingNavbar == 'Navbar3' && } +
+ {BookingNavbar != 'Navbar3' ? ( +
+
+ {UserType !== 'Employee' && ( +
+ {PricingAppPricingName?.[0]?.PricingName + + ' / ' + + PricingAppPricingName?.[0]?.Type}
)} - {!OtherServicesglobal && ( - - {' '} - - - )} - {!OtherServicesglobal && Kioskopen && ( - - )} - {SAdminuserPin?.length > 0 && UserType != 'Super Admin User' && ( -
- -
- )} - {CheckBookingStatus == 'Open' ? !OtherServicesglobal && ( -
- - {' '} - + item?.FeatureAddonName?.toLowerCase() === 'kiosk sales' + ) && + !sportsAppPreference && ( +
0 ? 'none' : 'auto', + opacity: OrderStatus > 0 ? 0.5 : 1, }} - /> - {/* */} + > + + + openModalKiosk()} + style={{ cursor: 'pointer', fontSize: '1.5rem' }} + className="iconsize" + /> + + +
+ )} + {!OtherServicesglobal && ( + + {' '} + -
- ) : ( -
- + )} + {!OtherServicesglobal && Kioskopen && ( + + )} + {SAdminuserPin?.length > 0 && + UserType != 'Super Admin User' && ( +
+ +
+ )} + {CheckBookingStatus == 'Open' ? ( + !OtherServicesglobal && ( +
+ + {' '} + + {/* */} + +
+ ) + ) : ( +
+ { /> - -
- )} - {!OtherServicesglobal && -
- - {''} - - -
} -
-
- ) : - - } -
-
-
- {!OtherServicesglobal && ( - - )} - {OtherServicesglobal && ( - - )} -
-
- {!OtherServicesglobal && Comboglobal === false && ( - - )} - {!OtherServicesglobal && Comboglobal === true && ( - - )} - {OtherServicesglobal && ( - - )} -
-
-
- {action ? ( - - ) : ( - <> - {BSLayout4Data?.BookingBilling?.[0] == 'Billing1' && ( - - )} - {BSLayout4Data?.BookingBilling?.[0] == 'Billing2' && ( - - )} - {BSLayout4Data?.BookingBilling?.[0] == 'Billing3' && ( - - )} - {BSLayout4Data?.BookingBilling?.[0] == 'Billing4' && ( - - )} - {BSLayout4Data?.BookingBilling?.[0] == 'Billing5' && ( - - )} - {BSLayout4Data?.BookingBilling?.[0] == 'Billing6' && ( - - )} - {BSLayout4Data?.BookingBilling?.[0] == 'Billing7' && ( - - )} - {BookingBilling == 'Billing8' && } - {BSLayout4Data?.BookingBilling?.[0] == 'StandardBilling' && ( -
-
)} - - )} - {/*
+ + {''} + + +
+ )} +
+
+ ) : ( + + )} +
+
+
+ {!OtherServicesglobal && ( + + )} + {OtherServicesglobal && ( + + )} +
+
+ {!OtherServicesglobal && Comboglobal === false && ( + + )} + {!OtherServicesglobal && Comboglobal === true && ( + + )} + {OtherServicesglobal && ( + + )} +
+
+
+ {action ? ( + + ) : ( + <> + {BSLayout4Data?.BookingBilling?.[0] == 'Billing1' && ( + + )} + {BSLayout4Data?.BookingBilling?.[0] == 'Billing2' && ( + + )} + {BSLayout4Data?.BookingBilling?.[0] == 'Billing3' && ( + + )} + {BSLayout4Data?.BookingBilling?.[0] == 'Billing4' && ( + + )} + {BSLayout4Data?.BookingBilling?.[0] == 'Billing5' && ( + + )} + {BSLayout4Data?.BookingBilling?.[0] == 'Billing6' && ( + + )} + {BSLayout4Data?.BookingBilling?.[0] == 'Billing7' && ( + + )} + {BookingBilling == 'Billing8' && } + {BSLayout4Data?.BookingBilling?.[0] == 'StandardBilling' && ( +
+ +
+ )} + + )} + {/*
*/} +
-
- {BookingModalOpen && !OtherServicesglobal && ( - - )} - {ListOfInvoices && !OtherServicesglobal && ( - - )} - + {BookingModalOpen && !OtherServicesglobal && ( + + )} + {ListOfInvoices && !OtherServicesglobal && ( + + )} + + ); }; diff --git a/src/Pages/BookingScreen/Template/BSLayout5/BSLayout5.jsx b/src/Pages/BookingScreen/Template/BSLayout5/BSLayout5.jsx index 3c69817..86d2efc 100644 --- a/src/Pages/BookingScreen/Template/BSLayout5/BSLayout5.jsx +++ b/src/Pages/BookingScreen/Template/BSLayout5/BSLayout5.jsx @@ -1,17 +1,42 @@ -import { React, useCallback, useEffect, useState } from 'react'; +import {lazy,useCallback, useEffect, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { isMobile } from 'react-device-detect'; import moment from 'moment'; import { Tooltip, Badge, Popconfirm } from 'antd'; -import BSNavbar1 from '../../Components/BSNavbar/BSNavbar1'; -import BSNavbar2 from '../../Components/BSNavbar/BSNavbar2'; -import BSBillingTable1 from '../../Components/BSBillingTables/BSBillingTable1/BSBTOverall1'; -import BSBillingTable2 from '../../Components/BSBillingTables/BSBillingTable2/BSBillingTable2'; -import BSBillingTable3 from '../../Components/BSBillingTables/BSBillingTable3/BSBillingTable3overall'; + +const BSNavbar1 = lazy(() => import('../../Components/BSNavbar/BSNavbar1')); + +const BSNavbar2 = lazy(() => import('../../Components/BSNavbar/BSNavbar2')); + +const BSBillingTable1 = lazy( + () => import('../../Components/BSBillingTables/BSBillingTable1/BSBTOverall1') +); + +const BSBillingTable2 = lazy( + () => + import('../../Components/BSBillingTables/BSBillingTable2/BSBillingTable2') +); + +const BSBillingTable3 = lazy( + () => + import('../../Components/BSBillingTables/BSBillingTable3/BSBillingTable3overall') +); + import BSBillingTable4 from '../../Components/BSBillingTables/BSBillingTable4/BSBillingTable4Full'; -import BSBillingTable5 from '../../Components/BSBillingTables/BSBillingTable5/BSBillingTable5'; -import BSBillingTable6 from '../../Components/BSBillingTables/BSBillingTable6/BSBTOverall6'; -import BSBillingTable7 from '../../Components/BSBillingTables/BSBillingTable7/BSBillingTable7Overall.jsx'; + +const BSBillingTable5 = lazy( + () => + import('../../Components/BSBillingTables/BSBillingTable5/BSBillingTable5') +); + +const BSBillingTable6 = lazy( + () => import('../../Components/BSBillingTables/BSBillingTable6/BSBTOverall6') +); + +const BSBillingTable7 = lazy( + () => + import('../../Components/BSBillingTables/BSBillingTable7/BSBillingTable7Overall.jsx') +); import BSItemCard from '../../Components/BSItemCards/BSItemCard'; import CategoryVertical from '../../Components/BSCategories/BSCategoryVertical'; import { dynamicComponentProps } from '../DynamicComponentProps.js'; @@ -45,7 +70,6 @@ import { globalKioskSalesCount, } from '../../../../Features/Kiosk/kiosk.js'; import SalesCountComponent from '../SalesCountComponent.jsx'; -import '../../../../Styles/BookingScreen/Template/BSLayout5/BSLayout5.scss'; import PozoKioskIcon from '../../Components/UtillComponents/Pozo retail icons/PozoKioskIcon.jsx'; import { GLobalSadminUserPin, @@ -66,9 +90,11 @@ import RetailBookingClosing from '../RetailBookingClose.jsx'; import ListOfSalesInvoices from '../../Components/BSBillingTables/ListofInvoices/ListOfSalesInvoices.jsx'; import BSEwayBillicon from '../../Components/UtillComponents/BSEwayBillicon.jsx'; import BSComboItemCard from '../../Components/BSItemCards/BSComboItemCard.jsx'; -import BranchTransferComponent from '../../Components/UtillComponents/BSQuickBranchToBranchTransferComponent.jsx'; +const BranchTransferComponent = lazy( + () => + import('../../Components/UtillComponents/BSQuickBranchToBranchTransferComponent.jsx') +); import BSExpireProductsList from '../../Components/UtillComponents/BSExpireProductsList.jsx'; - import BSOtherServiceItemCard from '../../Components/BSItemCards/BSOtherServiceItemCard.jsx'; import BSOtherServicesHorizontalcat from '../../Components/BSCategories/BSOtherServicesHorizontalcat'; import BSOtherServicesVerticalcat from '../../Components/BSCategories/BSOtherServicesVerticalcat.jsx'; @@ -79,6 +105,8 @@ import { CiShop } from 'react-icons/ci'; import BranchName from '../BranchName.jsx'; import ComboSalesBillTable from '../../Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx'; import PlanExpireNotification from '../PlanExpireNotification.jsx'; +const subDirectory = import.meta.env.BASE_URL; +const commonDirectory = import.meta.env.COMMON_BASE_URL; const BSLayout5 = () => { const dispatch = useDispatch(); @@ -115,13 +143,15 @@ const BSLayout5 = () => { const DineInAccess = SettingDataSelector?.[0]?.SettingDtlDetails.filter( (i) => i.SettingIdName === 'DineIn' )?.[0]; + const AppName = SessionData?.AppName; const AppId = SessionData?.AppId; const CompId = SessionData?.CompId; const BranchId = SessionData?.BranchId; const UserId = SessionData?.UserId; const UserType = SessionData?.UserType; const currentDateValue = moment().format('YYYY-MM-DD HH:mm:ss'); - + const animations = ['example1', 'example2', 'example3']; + let ss = animations[count]; let containerHeight = isMobile ? AppExpDate?.RemainingDays <= 7 || AppExpDate?.PlanType?.toLowerCase() === 'extend' ? '580px' diff --git a/src/Pages/BookingScreen/Template/BSLayout6/BSLayout6.jsx b/src/Pages/BookingScreen/Template/BSLayout6/BSLayout6.jsx index 7833192..35a5afa 100644 --- a/src/Pages/BookingScreen/Template/BSLayout6/BSLayout6.jsx +++ b/src/Pages/BookingScreen/Template/BSLayout6/BSLayout6.jsx @@ -1,19 +1,48 @@ -import React, { useEffect, useState, useCallback } from 'react'; +import React, { useEffect, useState, useCallback, lazy, Suspense } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { isMobile } from 'react-device-detect'; import moment from 'moment'; import { Tooltip, Badge, Popconfirm } from 'antd'; -import BSNavbar1 from '../../Components/BSNavbar/BSNavbar1'; -import BSNavbar2 from '../../Components/BSNavbar/BSNavbar2'; -import BSBillingTable1 from '../../Components/BSBillingTables/BSBillingTable1/BSBTOverall1'; -import BSBillingTable2 from '../../Components/BSBillingTables/BSBillingTable2/BSBillingTable2'; -import BSBillingTable3 from '../../Components/BSBillingTables/BSBillingTable3/BSBillingTable3overall'; -import BSBillingTable4 from '../../Components/BSBillingTables/BSBillingTable4/BSBillingTable4Full'; -import BSBillingTable5 from '../../Components/BSBillingTables/BSBillingTable5/BSBillingTable5'; -import BSBillingTable6 from '../../Components/BSBillingTables/BSBillingTable6/BSBTOverall6'; -import BSBillingTable7 from '../../Components/BSBillingTables/BSBillingTable7/BSBillingTable7Overall.jsx'; +const BSNavbar1 = lazy(() => import('../../Components/BSNavbar/BSNavbar1')); + +const BSNavbar2 = lazy(() => import('../../Components/BSNavbar/BSNavbar2')); + +const BSBillingTable1 = lazy( + () => import('../../Components/BSBillingTables/BSBillingTable1/BSBTOverall1') +); + +const BSBillingTable2 = lazy( + () => + import('../../Components/BSBillingTables/BSBillingTable2/BSBillingTable2') +); + +const BSBillingTable3 = lazy( + () => + import('../../Components/BSBillingTables/BSBillingTable3/BSBillingTable3overall') +); + +const BSBillingTable4 = lazy( + () => + import('../../Components/BSBillingTables/BSBillingTable4/BSBillingTable4Full') +); + +const BSBillingTable5 = lazy( + () => + import('../../Components/BSBillingTables/BSBillingTable5/BSBillingTable5') +); + +const BSBillingTable6 = lazy( + () => import('../../Components/BSBillingTables/BSBillingTable6/BSBTOverall6') +); + +const BSBillingTable7 = lazy( + () => + import('../../Components/BSBillingTables/BSBillingTable7/BSBillingTable7Overall.jsx') +); import BSItemCard from '../../Components/BSItemCards/BSItemCard'; -import CategoryHorizontal from '../../Components/BSCategories/BSCategoryHorizontal'; +const CategoryHorizontal = lazy( + () => import('../../Components/BSCategories/BSCategoryHorizontal') +); import { dynamicComponentProps } from '../DynamicComponentProps.js'; import { GlobalPricingAppPricingName, @@ -55,7 +84,6 @@ import { import { Messages } from '../../../../Components/Notifications/Messages.jsx'; import SAdminUserNotification from '../../Components/BookingFunctionality/SAdminUserNotification.jsx'; import SalesCountComponent from '../SalesCountComponent.jsx'; -import '../../../../Styles/BookingScreen/Template/BSLayout6/BSLayout6.scss'; import { getBookingStatus, GlobalBookingStatus, @@ -64,18 +92,29 @@ import { PutBookingClose } from '../../../../Features/BookingScreen/RetailBookin import TooltipWrapper from '../../../../Components/Tooltip/Tooltip.jsx'; import BookingCloseIcon from '../../Components/UtillComponents/BookingCloseIcon.jsx'; import RetailBookingClosing from '../RetailBookingClose.jsx'; -import ListOfSalesInvoices from '../../Components/BSBillingTables/ListofInvoices/ListOfSalesInvoices.jsx'; -import BSEwayBillicon from '../../Components/UtillComponents/BSEwayBillicon.jsx'; -import BSComboItemCard from '../../Components/BSItemCards/BSComboItemCard.jsx'; -import BranchTransferComponent from '../../Components/UtillComponents/BSQuickBranchToBranchTransferComponent.jsx'; -import BSExpireProductsList from '../../Components/UtillComponents/BSExpireProductsList.jsx'; +const ListOfSalesInvoices = lazy( + () => + import('../../Components/BSBillingTables/ListofInvoices/ListOfSalesInvoices.jsx') +); +const BSEwayBillicon = lazy( + () => import('../../Components/UtillComponents/BSEwayBillicon.jsx') +); +const BSComboItemCard = lazy( + () => import('../../Components/BSItemCards/BSComboItemCard.jsx') +); +const BranchTransferComponent = lazy( + () => + import('../../Components/UtillComponents/BSQuickBranchToBranchTransferComponent.jsx') +); +const BSExpireProductsList = lazy( + () => import('../../Components/UtillComponents/BSExpireProductsList.jsx') +); + import BSOtherServiceItemCard from '../../Components/BSItemCards/BSOtherServiceItemCard.jsx'; import BSOtherServicesHorizontalcat from '../../Components/BSCategories/BSOtherServicesHorizontalcat'; import BSNavbar3 from '../../Components/BSNavbar/BSNavbar3.jsx'; import SalesCountForStandard from '../SalesCountForStandard.jsx'; import StandardTable from '../../Components/BSBillingTables/StandardTable/StandardTable.jsx'; -import { CiShop } from 'react-icons/ci'; -import BranchName from '../BranchName.jsx'; import ComboSalesBillTable from '../../Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx'; import PlanExpireNotification from '../PlanExpireNotification.jsx'; const BSLayout6 = () => { @@ -112,10 +151,12 @@ const BSLayout6 = () => { const AppExpDate = useSelector(GlobalAppExpDateData); const [screenHeight, setScreenHeight] = useState(window?.innerHeight); // const [AppExpDate, setAppExpDate] = useState(0); + const [count, setcount] = useState(0); const BookingNavbar = BSLayout6Data?.BookingNavbar?.[0]; const BookingCategory = BSLayout6Data?.BookingCategory; const BookingCard = BSLayout6Data?.BookingCard; const BookingBilling = BSLayout6Data?.BookingBilling?.[0]; + const AppName = SessionData?.AppName; const AppId = SessionData?.AppId; const CompId = SessionData?.CompId; const BranchId = SessionData?.BranchId; @@ -128,12 +169,9 @@ const BSLayout6 = () => { )?.[0]; const currentDateValue = moment().format('YYYY-MM-DD HH:mm:ss'); - const tableData = useSelector(GlobalOrderCardDetails); const PricingAppPricingName = useSelector(GlobalPricingAppPricingName); const SAdminuserPin = useSelector(GLobalSadminUserPin); - const SelectedBillColor = useSelector(SelectedGlobalBillingColorDetail); - const [messageType, setMessageType] = useState(null); const [messageData, setMessageData] = useState(null); const [popOverOpen, setPopOverOpen] = useState(false); @@ -149,7 +187,6 @@ const BSLayout6 = () => { } }, [SessionData]); - useEffect(() => { if (AppId && CompId && BranchId && UserId) { fetchBookingStatus(); @@ -185,16 +222,17 @@ const BSLayout6 = () => { }; let containerHeight = isMobile - ? AppExpDate?.RemainingDays <= 7 || AppExpDate?.PlanType?.toLowerCase() === 'extend' + ? AppExpDate?.RemainingDays <= 7 || + AppExpDate?.PlanType?.toLowerCase() === 'extend' ? '577px' : '595px' - : UserType != 'Super Admin' && - UserType != 'Super Admin User' && - AppExpDate?.RemainingDays <= 7 || AppExpDate?.PlanType?.toLowerCase() === 'extend' + : (UserType != 'Super Admin' && + UserType != 'Super Admin User' && + AppExpDate?.RemainingDays <= 7) || + AppExpDate?.PlanType?.toLowerCase() === 'extend' ? '96vh' : '99vh'; - useEffect(() => { function handleResize() { setScreenHeight(window.innerHeight); @@ -207,7 +245,6 @@ const BSLayout6 = () => { }; }, []); - const openModalKiosk = () => { setKioskopen(true); }; @@ -277,312 +314,317 @@ const BSLayout6 = () => { setBookingModalOpen(false); }; return ( - <> - - {UserType != 'Super Admin' && - UserType != 'Super Admin User' && - (AppExpDate?.RemainingDays <= 30 || AppExpDate === 'undefined' || AppExpDate?.PlanType?.toLowerCase() === 'extend') && ( - - )} + Loading components...
}> + <> + + {UserType != 'Super Admin' && + UserType != 'Super Admin User' && + (AppExpDate?.RemainingDays <= 30 || + AppExpDate === 'undefined' || + AppExpDate?.PlanType?.toLowerCase() === 'extend') && ( + + )} -
-
-
- {BookingNavbar == 'Navbar1' && } - {BookingNavbar == 'Navbar2' && } - {BookingNavbar == 'Navbar3' && } -
- {BookingNavbar != 'Navbar3' ? ( -
-
- {UserType !== 'Employee' && ( -
- {PricingAppPricingName?.[0]?.PricingName + - ' / ' + - PricingAppPricingName?.[0]?.Type} -
- )} - {!OtherServicesglobal && ( - - )} - {!OtherServicesglobal && - SessionData?.FeatureAddonData?.FeatureDtls?.find( - (item) => - item?.FeatureAddonName?.toLowerCase() === 'kiosk sales' - ) && - !sportsAppPreference && ( -
0 ? 'none' : 'auto', - opacity: OrderStatus > 0 ? 0.5 : 1, - }} - > - - {''} - - openModalKiosk()} - style={{ cursor: 'pointer', fontSize: '1.5rem' }} - className="iconsize" - /> - - +
+
+
+ {BookingNavbar == 'Navbar1' && } + {BookingNavbar == 'Navbar2' && } + {BookingNavbar == 'Navbar3' && } +
+ {BookingNavbar != 'Navbar3' ? ( +
+
+ {UserType !== 'Employee' && ( +
+ {PricingAppPricingName?.[0]?.PricingName + + ' / ' + + PricingAppPricingName?.[0]?.Type}
)} - {!OtherServicesglobal && ( - - {' '} - - - )} - {!OtherServicesglobal && Kioskopen && ( - - )} - {SAdminuserPin?.length > 0 && - UserType != 'Super Admin User' && ( -
- -
+ {!OtherServicesglobal && ( + )} - {!OtherServicesglobal && ( - <> - {' '} - {CheckBookingStatus == 'Open' ? ( -
- - {' '} - - {/* */} - -
- ) : ( -
- - BookingOpenFun('Open')} + {!OtherServicesglobal && + SessionData?.FeatureAddonData?.FeatureDtls?.find( + (item) => + item?.FeatureAddonName?.toLowerCase() === 'kiosk sales' + ) && + !sportsAppPreference && ( +
0 ? 'none' : 'auto', + opacity: OrderStatus > 0 ? 0.5 : 1, + }} + > + + {''} + - - - - - + openModalKiosk()} + style={{ cursor: 'pointer', fontSize: '1.5rem' }} + className="iconsize" + /> + + +
+ )} + {!OtherServicesglobal && ( + + {' '} + + + )} + {!OtherServicesglobal && Kioskopen && ( + + )} + {SAdminuserPin?.length > 0 && + UserType != 'Super Admin User' && ( +
+ +
+ )} + {!OtherServicesglobal && ( + <> + {' '} + {CheckBookingStatus == 'Open' ? ( +
+ + {' '} + + {/* */} + +
+ ) : ( +
+ + BookingOpenFun('Open')} + > + + + + + +
+ )} + + )} + {!OtherServicesglobal && ( +
+ + {''} + + +
+ )} +
+
+ ) : ( + + )} +
+ {!OtherServicesglobal && Comboglobal === false && ( + + )} + {OtherServicesglobal && ( + + )} +
+
+ +
+
+ {!OtherServicesglobal && Comboglobal === false && ( + + )} + {!OtherServicesglobal && Comboglobal === true && ( + + )} + {OtherServicesglobal && ( + + )} +
+ +
+
+ {action ? ( + + ) : ( + <> + {BSLayout6Data?.BookingBilling?.[0] == 'Billing1' && ( + + )} + {BSLayout6Data?.BookingBilling?.[0] == 'Billing2' && ( + + )} + {BSLayout6Data?.BookingBilling?.[0] == 'Billing3' && ( + + )} + {BSLayout6Data?.BookingBilling?.[0] == 'Billing4' && ( + + )} + {BSLayout6Data?.BookingBilling?.[0] == 'Billing5' && ( + + )} + {BSLayout6Data?.BookingBilling?.[0] == 'Billing6' && ( + + )} + {BSLayout6Data?.BookingBilling?.[0] == 'Billing7' && ( + + )} + {BookingBilling == 'Billing8' && } + {BSLayout6Data?.BookingBilling?.[0] == + 'StandardBilling' && ( +
+
)} )} - {!OtherServicesglobal && ( -
- - {''} - - -
- )} -
-
- ) : ( - - )} -
- {!OtherServicesglobal && Comboglobal === false && ( - - )} - {OtherServicesglobal && ( - - )} -
-
- -
-
- {!OtherServicesglobal && Comboglobal === false && ( - - )} - {!OtherServicesglobal && Comboglobal === true && ( - - )} - {OtherServicesglobal && ( - - )} -
- -
-
- {action ? ( - - ) : ( - <> - {BSLayout6Data?.BookingBilling?.[0] == 'Billing1' && ( - - )} - {BSLayout6Data?.BookingBilling?.[0] == 'Billing2' && ( - - )} - {BSLayout6Data?.BookingBilling?.[0] == 'Billing3' && ( - - )} - {BSLayout6Data?.BookingBilling?.[0] == 'Billing4' && ( - - )} - {BSLayout6Data?.BookingBilling?.[0] == 'Billing5' && ( - - )} - {BSLayout6Data?.BookingBilling?.[0] == 'Billing6' && ( - - )} - {BSLayout6Data?.BookingBilling?.[0] == 'Billing7' && ( - - )} - {BookingBilling == 'Billing8' && } - {BSLayout6Data?.BookingBilling?.[0] == 'StandardBilling' && ( -
- -
- )} - - )} - {/*
*/} +
+ {BookingModalOpen && !OtherServicesglobal && ( + + )} + {ListOfInvoices && !OtherServicesglobal && ( + + )}
- {BookingModalOpen && !OtherServicesglobal && ( - - )} - {ListOfInvoices && !OtherServicesglobal && ( - - )} -
- + + ); }; export default BSLayout6; diff --git a/src/Pages/BookingScreen/Template/BSLayout7/BSCombo1.jsx b/src/Pages/BookingScreen/Template/BSLayout7/BSCombo1.jsx index 7036e02..3c44547 100644 --- a/src/Pages/BookingScreen/Template/BSLayout7/BSCombo1.jsx +++ b/src/Pages/BookingScreen/Template/BSLayout7/BSCombo1.jsx @@ -1,17 +1,38 @@ -import React, { useEffect, useState, useCallback } from 'react'; +import React, { useEffect, useState, useCallback, lazy, Suspense } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import moment from 'moment'; import { Tooltip, Badge, Popconfirm } from 'antd'; -import BSBillingTable1 from '../../Components/BSBillingTables/BSBillingTable1/BSBillingTable1'; -import BSBillingTable2 from '../../Components/BSBillingTables/BSBillingTable2/BsBill2'; -import BSBillingTable3 from '../../Components/BSBillingTables/BSBillingTable3/BSBillingTable3'; -import BSBillingTable4 from '../../Components/BSBillingTables/BSBillingTable4/BSBillingTable4'; -import BSBillingTable5 from '../../Components/BSBillingTables/BSBillingTable5/BsBill'; -import BSBillingTable6 from '../../Components/BSBillingTables/BSBillingTable6/BSBillingTable6'; -import BSBillingTable7 from '../../Components/BSBillingTables/BSBillingTable7/BSBillingTable7'; -import BSC1Payment from '../../Components/BSCombo/BSC1Payment'; -import BSC1NavBar from '../../Components/BSCombo/BSC1NavBar'; -import BSC1Search from '../../Components/BSCombo/BSC1Search'; +const BSBillingTable1 = lazy( + () => + import('../../Components/BSBillingTables/BSBillingTable1/BSBillingTable1') +); +const BSBillingTable2 = lazy( + () => import('../../Components/BSBillingTables/BSBillingTable2/BsBill2') +); +const BSBillingTable3 = lazy( + () => + import('../../Components/BSBillingTables/BSBillingTable3/BSBillingTable3') +); +const BSBillingTable4 = lazy( + () => + import('../../Components/BSBillingTables/BSBillingTable4/BSBillingTable4') +); +const BSBillingTable5 = lazy( + () => import('../../Components/BSBillingTables/BSBillingTable5/BsBill') +); +const BSBillingTable6 = lazy( + () => + import('../../Components/BSBillingTables/BSBillingTable6/BSBillingTable6') +); +const BSBillingTable7 = lazy( + () => + import('../../Components/BSBillingTables/BSBillingTable7/BSBillingTable7') +); + +// Combo components (lazy) +const BSC1Payment = lazy(() => import('../../Components/BSCombo/BSC1Payment')); +const BSC1NavBar = lazy(() => import('../../Components/BSCombo/BSC1NavBar')); +const BSC1Search = lazy(() => import('../../Components/BSCombo/BSC1Search')); import { GlobalCombosearch, GlobalPayementloader, @@ -29,8 +50,13 @@ import { import { isMobile } from 'react-device-detect'; import { ArrowUpOutlined } from '@ant-design/icons'; import { getSession } from '../../../../Services/Others.js'; -import BSNavBarComboSearch from '../../Components/UtillComponents/BSNavBarComboSearch.jsx'; -import BSKioskCounterPayment from '../../Components/UtillComponents/BSKioskCounterPayment.jsx'; +const BSNavBarComboSearch = lazy( + () => import('../../Components/UtillComponents/BSNavBarComboSearch.jsx') +); + +const BSKioskCounterPayment = lazy( + () => import('../../Components/UtillComponents/BSKioskCounterPayment.jsx') +); import { getKioskDatas, globalKioskSalesCount, @@ -58,21 +84,43 @@ import { import { PutBookingClose } from '../../../../Features/BookingScreen/RetailBookingClose.js'; import TooltipWrapper from '../../../../Components/Tooltip/Tooltip.jsx'; import BookingCloseIcon from '../../Components/UtillComponents/BookingCloseIcon.jsx'; -import RetailBookingClosing from '../RetailBookingClose.jsx'; -import ListOfSalesInvoices from '../../Components/BSBillingTables/ListofInvoices/ListOfSalesInvoices.jsx'; -import BSEwayBillicon from '../../Components/UtillComponents/BSEwayBillicon.jsx'; -import BranchTransferComponent from '../../Components/UtillComponents/BSQuickBranchToBranchTransferComponent.jsx'; -import BSExpireProductsList from '../../Components/UtillComponents/BSExpireProductsList.jsx'; -import ComboSalesBillTable from '../../Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx'; +const RetailBookingClosing = lazy(() => import('../RetailBookingClose.jsx')); + +const ListOfSalesInvoices = lazy( + () => + import('../../Components/BSBillingTables/ListofInvoices/ListOfSalesInvoices.jsx') +); + +const BranchTransferComponent = lazy( + () => + import('../../Components/UtillComponents/BSQuickBranchToBranchTransferComponent.jsx') +); + +const BSExpireProductsList = lazy( + () => import('../../Components/UtillComponents/BSExpireProductsList.jsx') +); + +const ComboSalesBillTable = lazy( + () => + import('../../Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx') +); import { GiBasket } from 'react-icons/gi'; import { FaRegKeyboard } from 'react-icons/fa'; import { CgSearchLoading } from 'react-icons/cg'; import { DefaultModal } from '../../../../Components/Modal/DefaultModal.jsx'; -import MultipleSearch from '../../Components/UtillComponents/MultipleSearch.jsx'; -import VerfiedProducts from '../../Components/BSNavbar/verfiedProduct/VerfiedProducts.jsx'; +const MultipleSearch = lazy( + () => import('../../Components/UtillComponents/MultipleSearch.jsx') +); + +const VerfiedProducts = lazy( + () => import('../../Components/BSNavbar/verfiedProduct/VerfiedProducts.jsx') +); import ShortcutKeyHelper from '../../Components/UtillComponents/ShortcutKeyHelper.jsx'; import PlanExpireNotification from '../PlanExpireNotification.jsx'; +const subDirectory = import.meta.env.BASE_URL; +const commonDirectory = import.meta.env.COMMON_BASE_URL; + export default function BSCombo1() { const dispatch = useDispatch(); const { action, selectedProducts } = useSelector( @@ -123,6 +171,7 @@ export default function BSCombo1() { item.SettingIdName === 'VerifyProduct' && item?.SettingValue === 'Y' ); + const AppName = SessionData?.AppName; const AppId = SessionData?.AppId; const CompId = SessionData?.CompId; const BranchId = SessionData?.BranchId; @@ -134,30 +183,11 @@ export default function BSCombo1() { ?.ScreenStatus ?? 'Open'; const [BookingModalOpen, setBookingModalOpen] = useState(false); const currentDateValue = moment().format('YYYY-MM-DD HH:mm:ss'); - + const animations = ['example1', 'example2', 'example3']; + let ss = animations[count]; const [ListOfInvoices, setListOfInvoices] = useState(false); const [ComboDropDown, setComboDropDown] = useState(); - const [isAltPressed, setIsAltPressed] = useState(false); - - useEffect(() => { - const handleKeyDown = (e) => { - if (e.key === 'F2') setIsAltPressed(true); - }; - - const handleKeyUp = (e) => { - if (e.key === 'F2') setIsAltPressed(false); - }; - - window.addEventListener('keydown', handleKeyDown); - window.addEventListener('keyup', handleKeyUp); - - return () => { - window.removeEventListener('keydown', handleKeyDown); - window.removeEventListener('keyup', handleKeyUp); - }; - }, []); - useEffect(() => { fetchAmount(); if ( @@ -169,6 +199,15 @@ export default function BSCombo1() { } }, [SessionData]); + useEffect(() => { + if (AppExpDate?.RemainingDays <= 7) { + const interval = setInterval(() => { + setcount((prevCount) => (prevCount >= 2 ? 0 : prevCount + 1)); + }, 22000); + + return () => clearInterval(interval); + } + }, [count == 2]); useEffect(() => { Combodata(); if (AppId && CompId && BranchId && UserId) { @@ -294,314 +333,327 @@ export default function BSCombo1() { } }; return ( - <> - - {UserType != 'Super Admin' && - UserType != 'Super Admin User' && - (AppExpDate?.RemainingDays <= 7 || - AppExpDate === 'undefined' || - AppExpDate?.PlanType?.toLowerCase() === 'extend') && ( - - )} + Loading...
}> + <> + + {UserType != 'Super Admin' && + UserType != 'Super Admin User' && + (AppExpDate?.RemainingDays <= 7 || + AppExpDate === 'undefined' || + AppExpDate?.PlanType?.toLowerCase() === 'extend') && ( + + )} - {/* Combo Container */} -
-
- -
- {/* Multiple search */} - -
- setMultiple(true)} /> -
-
- {Comboglobal === false && ( - - - - )} - {Comboglobal === true && ( - -
-
-
- -
-
+ {/* Combo Container */} +
+
+ +
+ {/* Multiple search */} + +
+ setMultiple(true)} />
- )} + {Comboglobal === false && ( + + + + )} + {Comboglobal === true && ( + +
+
+
+ +
+
+
+
+ )} - {/*
*/} -
- {UserType !== 'Employee' && ( -
-

{PricingAppPricingName?.[0]?.PricingName}

-

{PricingAppPricingName?.[0]?.Type}

- {/* {PricingAppPricingName?.[0]?.PricingName + + {/*
*/} +
+ {UserType !== 'Employee' && ( +
+

{PricingAppPricingName?.[0]?.PricingName}

+

{PricingAppPricingName?.[0]?.Type}

+ {/* {PricingAppPricingName?.[0]?.PricingName + ' / ' + PricingAppPricingName?.[0]?.Type} */} -
- )} - - {SessionData?.FeatureAddonData?.FeatureDtls?.find( - (item) => - item?.FeatureAddonName?.toLowerCase() === 'kiosk sales' - ) && - !sportsAppPreference && ( -
0 ? 'none' : 'auto', - opacity: OrderStatus > 0 ? 0.5 : 1, - }} - > - - {''} - - openModalKiosk()} - style={{ cursor: 'pointer', fontSize: '1.5rem' }} - className="iconsize" - /> - -
)} - {Kioskopen && ( - - )} - {SAdminuserPin?.length > 0 && UserType != 'Super Admin User' && ( -
- -
- )} - -
- - {/* LOW STOCK ALERT */} -
- - {' '} - - -
- - {CheckBookingStatus == 'Open' ? ( -
- - {' '} - - {/* */} - -
- ) : ( -
- - BookingOpenFun('Open')} - > - - - - - -
- )} - {/* Verify Products */} - {VerifyTheProducts && ( - -
- -
-
- )} -
- {ComboDropDown?.length >= 1 && ( + {SessionData?.FeatureAddonData?.FeatureDtls?.find( + (item) => + item?.FeatureAddonName?.toLowerCase() === 'kiosk sales' + ) && + !sportsAppPreference && (
0 ? 'none' : 'auto', + opacity: OrderStatus > 0 ? 0.5 : 1, }} > - - + {''} + + openModalKiosk()} + style={{ cursor: 'pointer', fontSize: '1.5rem' }} + className="iconsize" + /> + + +
+ )} + + {Kioskopen && ( + + )} + {SAdminuserPin?.length > 0 && + UserType != 'Super Admin User' && ( +
+ +
+ )} + +
+ + {/* LOW STOCK ALERT */} +
+ + {' '} + + +
+ + {CheckBookingStatus == 'Open' ? ( +
+ + {' '} + + {/* */} + +
+ ) : ( +
+ + BookingOpenFun('Open')} + > + + + +
)} -
- {/* {preferenceshortcutkey && ( + {/* Verify Products */} + {VerifyTheProducts && ( + +
+ +
+
+ )} +
+ {ComboDropDown?.length >= 1 && ( +
+ + + +
+ )} +
+ {/* {preferenceshortcutkey && (
)} */} +
+ {/*
*/}
- {/*
*/}
-
-
- {/*
*/}
- {action ? ( - - ) : ( - // - <> - {BookingBilling == 'Billing1' && } - {BookingBilling == 'Billing2' && } - {BookingBilling == 'Billing3' && } - {BookingBilling == 'Billing4' && } - {BookingBilling == 'Billing5' && } - {BookingBilling == 'Billing6' && } - {BookingBilling == 'Billing7' && } - {BookingBilling == 'Billing8' && } - - )} -
- -
- -
-
- {paymentloader === true && ( -
-
-
-
 
-
-
-
 
-
-
-
 
-
-
-
 
-
-

- {' '} - Please wait while we process your payment -

- {PaymentTransactionNumber != null && ( -

- Transaction Number : {PaymentTransactionNumber} -

+ {/*
*/} +
+ {action ? ( + + ) : ( + // + <> + {BookingBilling == 'Billing1' && } + {BookingBilling == 'Billing2' && } + {BookingBilling == 'Billing3' && } + {BookingBilling == 'Billing4' && } + {BookingBilling == 'Billing5' && } + {BookingBilling == 'Billing6' && } + {BookingBilling == 'Billing7' && } + {BookingBilling == 'Billing8' && } + )}
+ +
+ +
+ {paymentloader === true && ( +
+
+
+
 
+
+
+
 
+
+
+
 
+
+
+
 
+
+

+ {' '} + Please wait while we process your payment +

+ {PaymentTransactionNumber != null && ( +

+ Transaction Number : {PaymentTransactionNumber} +

+ )} +
+
+ )} +
+ {BookingModalOpen && ( + )} -
- {BookingModalOpen && ( - + )} + setMultiple(false)} + destroyOnClose={true} + children={ + <> + + + } /> - )} - {ListOfInvoices && ( - - )} - setMultiple(false)} - destroyOnClose={true} - children={ - <> - - - } - /> - + + ); } diff --git a/src/Pages/BookingScreen/Template/PlanExpireNotification.jsx b/src/Pages/BookingScreen/Template/PlanExpireNotification.jsx index 505eee1..a553934 100644 --- a/src/Pages/BookingScreen/Template/PlanExpireNotification.jsx +++ b/src/Pages/BookingScreen/Template/PlanExpireNotification.jsx @@ -19,7 +19,7 @@ import "../../../Styles/BookingScreen/Template/BSLayout3/BSLayout3.scss"; const subDirectory = import.meta.env.ENV_BASE_URL; const commonDirectory = import.meta.env.ENV_COMMON_BASE_URL; -console.log('commonDirectory', commonDirectory); + const PlanExpireNotification = () => { const navigate = useNavigate(); const dispatch = useDispatch(); diff --git a/src/Pages/BookingScreen/Template/SalesCountComponent.jsx b/src/Pages/BookingScreen/Template/SalesCountComponent.jsx index 99b6ce3..32ed2a8 100644 --- a/src/Pages/BookingScreen/Template/SalesCountComponent.jsx +++ b/src/Pages/BookingScreen/Template/SalesCountComponent.jsx @@ -4,6 +4,8 @@ import React, { useEffect, useRef, useCallback, + lazy, + Suspense, } from 'react'; import { Tooltip } from 'antd'; import { @@ -12,38 +14,48 @@ import { getSession, } from '../../../Services/Others'; import { useDispatch } from 'react-redux'; +import { MdOutlineCallReceived } from 'react-icons/md'; +import { GoPackageDependencies } from 'react-icons/go'; +import { Messages } from '../../../Components/Notifications/Messages'; +import { useSelector } from 'react-redux'; +import { DefaultModal } from '../../../Components/Modal/DefaultModal'; import { getCardDataWithoutSub, getCardDataWithoutSubmodule, getLayoutproductCard, - getPreferenceData, getSelectedFavItems, GlobalProductCategorie, GlobalProductSubCategorie, GlobalSalesDetailData, PreferenceData, } from '../../../Features/BookingScreen/BookingData/BookingData'; -import './SalesCountComponent.scss'; -import { Messages } from '../../../Components/Notifications/Messages'; -import { useSelector } from 'react-redux'; import { ApplicationPreferences } from '../../../Features/BrachLogin/BranchLogin'; -import { DefaultModal } from '../../../Components/Modal/DefaultModal'; -import { Tables } from '../../../Components/Tables/Table'; -import CustomisedInvoiceChange from '../Components/UtillComponents/CustomisedInvoiceChange.jsx'; -import ProductPriceChange from '../Components/UtillComponents/ProductPriceChange.jsx'; -import ReceivedStocksModal from '../../../Components/Modal/ReceivedStocksModal.jsx'; -import ProductDetailsModal from '../../../Components/Modal/ProductDetailsModal.jsx'; -import { MdOutlineCallReceived } from 'react-icons/md'; -import { IoEye } from 'react-icons/io5'; -import { TiTickOutline } from 'react-icons/ti'; import { getReceivedStocks, PostReceiveStocks, } from '../../../Features/stockReceivedGodown/ReceivedStock.js'; -import { GoPackageDependencies } from 'react-icons/go'; import { getTemplateData } from '../../../Features/ThemeChange/ThemeChange.js'; -import ShortcutKeyHelper from '../Components/UtillComponents/ShortcutKeyHelper.jsx'; -import AllSalesPageSettings from '../Components/UtillComponents/AllSalesPageSettings.jsx'; +// Jsx Files +const CustomisedInvoiceChange = lazy( + () => import('../Components/UtillComponents/CustomisedInvoiceChange.jsx') +); +const AllSalesPageSettings = lazy( + () => import('../Components/UtillComponents/AllSalesPageSettings.jsx') +); +const ProductPriceChange = lazy( + () => import('../Components/UtillComponents/ProductPriceChange.jsx') +); +const ReceivedStocksModal = lazy( + () => import('../../../Components/Modal/ReceivedStocksModal.jsx') +); +const ProductDetailsModal = lazy( + () => import('../../../Components/Modal/ProductDetailsModal.jsx') +); +const ShortcutKeyHelper = lazy( + () => import('../Components/UtillComponents/ShortcutKeyHelper.jsx') +); +// Scss +import './SalesCountComponent.scss'; const SalesCountComponent = React.memo( ({ DineInAccess, GlobalsalesDetailData }) => { @@ -121,26 +133,6 @@ const SalesCountComponent = React.memo( const startIndex = (currentPage - 1) * rowsPerPage; const currentData = bookings?.slice(startIndex, startIndex + rowsPerPage); - const [isAltPressed, setIsAltPressed] = useState(false); - - useEffect(() => { - const handleKeyDown = (e) => { - if (e.key === 'F2') setIsAltPressed(true); - }; - - const handleKeyUp = (e) => { - if (e.key === 'F2') setIsAltPressed(false); - }; - - window.addEventListener('keydown', handleKeyDown); - window.addEventListener('keyup', handleKeyUp); - - return () => { - window.removeEventListener('keydown', handleKeyDown); - window.removeEventListener('keyup', handleKeyUp); - }; - }, []); - console.log(dailySalesData, 'dailySalesDatadailySalesData', bookings); function safeRound(amountStr) { @@ -206,20 +198,22 @@ const SalesCountComponent = React.memo( isMobile, ]); useEffect(() => { - getPreference(); - getReceivedStock(); + if (preferencedata?.length > 0) { + getPreference(); - let AutoReceiveStock = preferencedata?.[0]?.SettingDtlDetails?.some( - (s) => - s?.SettingIdName?.toLowerCase() === 'autoreceivestock' && - s?.SettingValue === 'Y' - ); - setAutoReceiveStock(!AutoReceiveStock); + let AutoReceiveStock = preferencedata?.[0]?.SettingDtlDetails?.some( + (s) => + s?.SettingIdName?.toLowerCase() === 'autoreceivestock' && + s?.SettingValue === 'Y' + ); + setAutoReceiveStock(!AutoReceiveStock); + if (AutoReceiveStock) { + getReceivedStock(); + } + } }, [preferencedata]); const getPreference = async () => { - // const data = { AppId: AppId, CompId: CompId, BranchId: BranchId }; - // const { data: res } = await dispatch(getPreferenceData(data)).unwrap(); const decimalSetting = preferencedata?.[0]?.SettingDtlDetails?.find( (setting) => setting?.SettingIdName?.toLowerCase() === 'decimal' && @@ -341,26 +335,6 @@ const SalesCountComponent = React.memo( align: 'center', width: '120px', }, - - // { - // title: 'Product Details', - // dataIndex: 'ProductDetails', - // key: 'ProductDetails', - // width: '120px', - // align: 'center', - // render: (text, record, index) => ( - // { - - // handleModalOpen(index) - // }} - // > - // - // - // ), - - // }, { title: 'Actions', dataIndex: 'fromBranch', @@ -500,658 +474,660 @@ const SalesCountComponent = React.memo( setModalProductDetails([]); }; return ( - <> - -
- {tooltipContent} - {DineInAccess?.SettingValue === 'Y' && - takeAwayPreference && - (TakeAwayOrderCount > 0 || - SelfTakeAwayOrderCount > 0 || - PreOrderAmount > 0) && ( - -
-
-

Admin + Staff :

- {SelfTakeAwayAmount != 0 &&

Self Booking :

} - {PreOrderAmount != 0 &&

Preorder :

} - {OverAllTakeAwayOfferAmount != 0 &&

Offer(-) :

} -
-
-

{safeRound(TakeAwayAmount)}

- {SelfTakeAwayAmount != 0 && ( -

{safeRound(SelfTakeAwayAmount)}

- )} - {PreOrderAmount != 0 && ( -

{safeRound(PreOrderAmount)}

- )} - {OverAllTakeAwayOfferAmount != 0 && ( -

{safeRound(OverAllTakeAwayOfferAmount)}

- )} -
-
-
+ Loading…
}> + <> + +
+ {tooltipContent} + {DineInAccess?.SettingValue === 'Y' && + takeAwayPreference && + (TakeAwayOrderCount > 0 || + SelfTakeAwayOrderCount > 0 || + PreOrderAmount > 0) && ( + -
Total
-
- {safeRound( - TakeAwayAmount + - SelfTakeAwayAmount + - PreOrderAmount - - OverAllTakeAwayOfferAmount - )} +
+
+

Admin + Staff :

+ {SelfTakeAwayAmount != 0 &&

Self Booking :

} + {PreOrderAmount != 0 &&

Preorder :

} + {OverAllTakeAwayOfferAmount != 0 && ( +

Offer(-) :

+ )} +
+
+

{safeRound(TakeAwayAmount)}

+ {SelfTakeAwayAmount != 0 && ( +

{safeRound(SelfTakeAwayAmount)}

+ )} + {PreOrderAmount != 0 && ( +

{safeRound(PreOrderAmount)}

+ )} + {OverAllTakeAwayOfferAmount != 0 && ( +

{safeRound(OverAllTakeAwayOfferAmount)}

+ )} +
+
+
+
+
Total
+
+ {safeRound( + TakeAwayAmount + + SelfTakeAwayAmount + + PreOrderAmount - + OverAllTakeAwayOfferAmount + )} +
-
- } - > -

- {isMobile ? 'TA' : 'Take Away'}:{' '} - - {safeRound( - (TakeAwayAmount || - 0 + SelfTakeAwayAmount || - 0 + PreOrderAmount || - 0) - OverAllTakeAwayOfferAmount - )} - -

+ } + > +

+ {isMobile ? 'TA' : 'Take Away'}:{' '} + + {safeRound( + (TakeAwayAmount || + 0 + SelfTakeAwayAmount || + 0 + PreOrderAmount || + 0) - OverAllTakeAwayOfferAmount + )} + +

- {/*

+ {/*

Take Away: {Math.round(((TakeAwayAmount + SelfTakeAwayAmount + PreOrderAmount) - OverAllTakeAwayOfferAmount)) || 0}

*/} - - )} - {DineInAccess?.SettingValue === 'Y' && - dinePreference && - (DineInOrderCount > 0 || SelfDineInOrderCount > 0) && ( - -
-
-

Admin + Staff :

- {SelfDineInAmount != 0 &&

Self Booking :

} - {OverAllDineInOfferAmount != 0 &&

Offer(-) :

} -
-
-

{safeRound(DineInAmount)}

- {SelfDineInAmount != 0 && ( -

{safeRound(SelfDineInAmount)}

- )} - {OverAllDineInOfferAmount != 0 && ( -

{safeRound(OverAllDineInOfferAmount)}

- )} -
-
-
+
+ )} + {DineInAccess?.SettingValue === 'Y' && + dinePreference && + (DineInOrderCount > 0 || SelfDineInOrderCount > 0) && ( + -
Total
-
- {safeRound( - DineInAmount + - SelfDineInAmount - - OverAllDineInOfferAmount - )} +
+
+

Admin + Staff :

+ {SelfDineInAmount != 0 &&

Self Booking :

} + {OverAllDineInOfferAmount != 0 &&

Offer(-) :

} +
+
+

{safeRound(DineInAmount)}

+ {SelfDineInAmount != 0 && ( +

{safeRound(SelfDineInAmount)}

+ )} + {OverAllDineInOfferAmount != 0 && ( +

{safeRound(OverAllDineInOfferAmount)}

+ )} +
+
+
+
+
Total
+
+ {safeRound( + DineInAmount + + SelfDineInAmount - + OverAllDineInOfferAmount + )} +
-
- } - > -

- {isMobile ? 'DI' : 'Dine In'}:{' '} - - {safeRound( - DineInAmount + SelfDineInAmount - OverAllDineInOfferAmount - )} - -

- {/*

+ } + > +

+ {isMobile ? 'DI' : 'Dine In'}:{' '} + + {safeRound( + DineInAmount + + SelfDineInAmount - + OverAllDineInOfferAmount + )} + +

+ {/*

Dine In: {Math.round(((DineInAmount + SelfDineInAmount) - OverAllDineInOfferAmount)) || 0}

*/} - - )} - -

- safeRound( - (TakeAwayAmount + - SelfTakeAwayAmount + - PreOrderAmount - - OverAllTakeAwayOfferAmount || 0) + - (DineInAmount + SelfDineInAmount - OverAllDineInOfferAmount) - ) > 0 && setIsNetAmtModalOpen(true) - } - > - {isMobile ? 'NA' : 'Net Amt'}:{' '} - - {safeRound( - (TakeAwayAmount + - SelfTakeAwayAmount + - PreOrderAmount - - OverAllTakeAwayOfferAmount || 0) + - (DineInAmount + SelfDineInAmount - OverAllDineInOfferAmount) + )} - -

- {Customisebillno && } - {/* Modal with table for multiple bookings */} - setIsModalOpen(false)} - handleSubmit={() => setIsModalOpen(false)} - width={700} - footer={false} - > -
- - - - - - - - {/* */} - - - - - - {currentData?.length > 0 ? ( - currentData?.map((item, index) => ( - - (e.currentTarget.style.backgroundColor = '#d6e4ff') - } - onMouseLeave={(e) => - (e.currentTarget.style.backgroundColor = - index % 2 === 0 ? '#f7faff' : '#e9f1ff') - } - > - - - - - {/* */} - - - - )) - ) : ( - - - - )} - -
- S.No - - Order ID - - Customer - - Mobile - Booked By - Payment Type - - Amount (₹) -
- {startIndex + index + 1} - - {extractLastNumberOrderId(item.OrderId)} - - {item.CustName || '—'} - - {item.CustMobile || '—'} - - {item.BookedBy || "—"} - - {item.PaymentTypeName || '—'} - - ₹{item.Amount?.toLocaleString()} -
- No booking data available -
- - {/* Pagination */} - {totalPages > 1 && ( -
+ safeRound( + (TakeAwayAmount + + SelfTakeAwayAmount + + PreOrderAmount - + OverAllTakeAwayOfferAmount || 0) + + (DineInAmount + SelfDineInAmount - OverAllDineInOfferAmount) + ) > 0 && setIsNetAmtModalOpen(true) + } + > + {isMobile ? 'NA' : 'Net Amt'}:{' '} + + {safeRound( + (TakeAwayAmount + + SelfTakeAwayAmount + + PreOrderAmount - + OverAllTakeAwayOfferAmount || 0) + + (DineInAmount + SelfDineInAmount - OverAllDineInOfferAmount) + )} + +

+ {Customisebillno && } + {/* Modal with table for multiple bookings */} + setIsModalOpen(false)} + handleSubmit={() => setIsModalOpen(false)} + width={700} + footer={false} + > +
+ - {currentPage == 1 ? ( - '' - ) : ( + + + + + + + {/* */} + + + + + + + {currentData?.length > 0 ? ( + currentData?.map((item, index) => ( + + (e.currentTarget.style.backgroundColor = '#d6e4ff') + } + onMouseLeave={(e) => + (e.currentTarget.style.backgroundColor = + index % 2 === 0 ? '#f7faff' : '#e9f1ff') + } + > + + + + + {/* */} + + + + )) + ) : ( + + + + )} + +
+ S.No + + Order ID + + Customer + + Mobile + Booked By + Payment Type + + Amount (₹) +
+ {startIndex + index + 1} + + {extractLastNumberOrderId(item.OrderId)} + + {item.CustName || '—'} + + {item.CustMobile || '—'} + + {item.BookedBy || "—"} + + {item.PaymentTypeName || '—'} + + ₹{item.Amount?.toLocaleString()} +
+ No booking data available +
+ + {/* Pagination */} + {totalPages > 1 && ( +
+ {currentPage == 1 ? ( + '' + ) : ( + + )} + + + Page {currentPage} of {totalPages} + + - )} +
+ )} +
+
- - Page {currentPage} of {totalPages} - - - -
- )} -
-
- - {/* Modal with table for multiple Net Amt */} - setIsNetAmtModalOpen(false)} - handleSubmit={() => setIsNetAmtModalOpen(false)} - width={800} - footer={false} - > -
- - - - - - - - - - - - - - - - - - - - - - - - - - {orderDetails?.map((item, index) => { - const total = - (item.CashAmount || 0) + - (item.UpiAmount || 0) + - (item.CardAmount || 0) + - (item.CreditAmount || 0); - - return ( - - (e.currentTarget.style.backgroundColor = '#e6f2ff') - } - onMouseLeave={(e) => - (e.currentTarget.style.backgroundColor = - index % 2 === 0 ? '#f7faff' : '#ffffff') - } + {/* Modal with table for multiple Net Amt */} + setIsNetAmtModalOpen(false)} + handleSubmit={() => setIsNetAmtModalOpen(false)} + width={800} + footer={false} + > +
+
- Cash - - UPI - - Card - - Credit - - Business UPI - - Total -
- Count - - Amt - - Count - - Amt - - Count - - Amt - - Count - - Amt - - Count - - Amt -
+ + + - - - - - - - - - - - - ); - })} - -
- - {item.CashCount} - - {item.CashAmount} - - {item.UpiCount} - - {item.UpiAmount} - - {item.CardCount} - - {item.CardAmount} - - {item.CreditCount} - - {item.CreditAmount} - - {item.BusinessUpiCount} - - {item.BusinessUpiAmount} - - {total} -
-
-
- - {TableData?.length > 0 && AutoReceiveStock && ( - - )} - -
- {/* {preferenceshortcutkey && } */} - {preferenceshortcutkey && ( -
- -
- )} - - - - - { - setIsReceivedModelOpen(false); - }} - columns={columns} - tableData={TableData} - handlePageChange={handlePageChange} - customTable={false} - /> + Cash + + + UPI + + + Card + + + Credit + + + Business UPI + + + Total + + + + + Count + + + Amt + + + Count + + + Amt + + + Count + + + Amt + + + Count + + + Amt + + + Count + + + Amt + + + - setModalProductDetails(d)} - onSubmit={handleModalSubmit} - /> - + + {orderDetails?.map((item, index) => { + const total = + (item.CashAmount || 0) + + (item.UpiAmount || 0) + + (item.CardAmount || 0) + + (item.CreditAmount || 0); + + return ( + + (e.currentTarget.style.backgroundColor = '#e6f2ff') + } + onMouseLeave={(e) => + (e.currentTarget.style.backgroundColor = + index % 2 === 0 ? '#f7faff' : '#ffffff') + } + > + + {item.CashCount} + + + {item.CashAmount} + + + {item.UpiCount} + + + {item.UpiAmount} + + + {item.CardCount} + + + {item.CardAmount} + + + {item.CreditCount} + + + {item.CreditAmount} + + + {item.BusinessUpiCount} + + + {item.BusinessUpiAmount} + + + {total} + + + ); + })} + + +
+ + + {TableData?.length > 0 && AutoReceiveStock && ( + + )} + +
+ {preferenceshortcutkey && ( +
+ +
+ )} + + + { + setIsReceivedModelOpen(false); + }} + columns={columns} + tableData={TableData} + handlePageChange={handlePageChange} + customTable={false} + /> + + setModalProductDetails(d)} + onSubmit={handleModalSubmit} + /> + + ); } ); diff --git a/src/Pages/BookingScreen/Template/SalesCountForStandard.jsx b/src/Pages/BookingScreen/Template/SalesCountForStandard.jsx index 897bb1a..6a69864 100644 --- a/src/Pages/BookingScreen/Template/SalesCountForStandard.jsx +++ b/src/Pages/BookingScreen/Template/SalesCountForStandard.jsx @@ -1,7 +1,15 @@ -import { useEffect, useState, useMemo, useCallback } from 'react'; +import { + useEffect, + useState, + useMemo, + useCallback, + lazy, + Suspense, + useRef, +} from 'react'; import { useSelector, useDispatch } from 'react-redux'; import { FaChartLine, FaRupeeSign } from 'react-icons/fa'; -import { Badge, DatePicker, Popconfirm, Tooltip } from 'antd'; +import { Badge, Popconfirm, Tooltip } from 'antd'; import { isMobile } from 'react-device-detect'; import { ApplicationPreferences } from '../../../Features/BrachLogin/BranchLogin'; import { @@ -25,12 +33,9 @@ import { import { useDateStore } from '../../../Features/BookingScreen/BookingData/DateStore'; import dayjs from 'dayjs'; import moment from 'moment'; -import { BsUiChecks } from 'react-icons/bs'; -import { FaCheckToSlot } from 'react-icons/fa6'; import PozoKioskIcon from '../Components/UtillComponents/Pozo retail icons/PozoKioskIcon'; import { globalKioskSalesCount } from '../../../Features/Kiosk/kiosk'; import BSKioskCounterPayment from '../Components/UtillComponents/BSKioskCounterPayment'; -import BSExpireProductsList from '../Components/UtillComponents/BSExpireProductsList'; import TooltipWrapper from '../../../Components/Tooltip/Tooltip'; import { getTemplateData, @@ -44,43 +49,68 @@ import { } from '../../../Features/Payment/PaymentReceivedRetail/PaymentReceivedRetail'; import { PutBookingClose } from '../../../Features/BookingScreen/RetailBookingClose'; import BSEwayBillicon from '../../BookingScreen/Components/UtillComponents/BSEwayBillicon.jsx'; -import ListOfSalesInvoices from '../Components/BSBillingTables/ListofInvoices/ListOfSalesInvoices.jsx'; import { DefaultModal } from '../../../Components/Modal/DefaultModal.jsx'; -import CustomisedInvoiceChange from '../Components/UtillComponents/CustomisedInvoiceChange.jsx'; -import ProductPriceChange from '../Components/UtillComponents/ProductPriceChange.jsx'; import { MdOutlineCallReceived } from 'react-icons/md'; import { getReceivedStocks, PostReceiveStocks, } from '../../../Features/stockReceivedGodown/ReceivedStock.js'; -import ReceivedStocksModal from '../../../Components/Modal/ReceivedStocksModal.jsx'; -import ProductDetailsModal from '../../../Components/Modal/ProductDetailsModal.jsx'; import { GoPackageDependencies } from 'react-icons/go'; import { Messages } from '../../../../ownLib/my-ui-lib.js'; +// Jsx File +const BSExpireProductsList = lazy( + () => import('../Components/UtillComponents/BSExpireProductsList') +); -import ShortcutKeyHelper from '../Components/UtillComponents/ShortcutKeyHelper.jsx'; -import AllSalesPageSettings from '../Components/UtillComponents/AllSalesPageSettings.jsx'; +const ListOfSalesInvoices = lazy( + () => + import('../Components/BSBillingTables/ListofInvoices/ListOfSalesInvoices.jsx') +); + +const CustomisedInvoiceChange = lazy( + () => import('../Components/UtillComponents/CustomisedInvoiceChange.jsx') +); + +const ProductPriceChange = lazy( + () => import('../Components/UtillComponents/ProductPriceChange.jsx') +); + +const ReceivedStocksModal = lazy( + () => import('../../../Components/Modal/ReceivedStocksModal.jsx') +); + +const ProductDetailsModal = lazy( + () => import('../../../Components/Modal/ProductDetailsModal.jsx') +); + +const ShortcutKeyHelper = lazy( + () => import('../Components/UtillComponents/ShortcutKeyHelper.jsx') +); + +const AllSalesPageSettings = lazy( + () => import('../Components/UtillComponents/AllSalesPageSettings.jsx') +); + +// Scss import '../../../Styles/BookingScreen/Template/BSLayout2/BSLayout2.scss'; +import useWhyDidYouUpdate from '../../../Services/findrerender.js'; +import React from 'react'; -const SalesCountForStandard = ({ - DineInAccess, - GlobalsalesDetailData, - PricingAppPricingName, -}) => { +const SalesCountForStandard = React.memo(() => { const dispatch = useDispatch(); const AppId = getSession('AppId'); const CompId = getSession('CompId'); + const BranchId = getSession('BranchId'); const UserId = getSession('UserId'); const ProdSubCat = useSelector(GlobalProductSubCategorie); const prodCat = useSelector(GlobalProductCategorie); const templateData = useSelector(getTemplateData); - const [selectedRowKeys, setSelectedRowKeys] = useState([]); const [allowDecimal, setAllowDecimal] = useState(false); const [BookingModalOpen, setBookingModalOpen] = useState(false); const [ListOfInvoices, setListOfInvoices] = useState(false); - const { selectedDate, setSelectedDate } = useDateStore(); + const [Kioskopen, setKioskopen] = useState(false); const badgeCount = useSelector(globalKioskSalesCount); const OtherServicesglobal = useSelector(GlobalOtherSevices); @@ -88,6 +118,7 @@ const SalesCountForStandard = ({ const SessionData = useSelector(StoredSessionData); const OrderStatus = useSelector(GlobalOrderStatus); const dailySalesData = useSelector(GlobalSalesDetailData); + const [page, setpage] = useState(1); const [isModalOpen, setIsModalOpen] = useState(false); const [isNetAmtModalOpen, setIsNetAmtModalOpen] = useState(false); @@ -110,6 +141,11 @@ const SalesCountForStandard = ({ const currentData = bookings?.slice(startIndex, startIndex + rowsPerPage); const preferencedata = useSelector(PreferenceData); + const DineInAccess = useMemo(() => { + return preferencedata?.[0]?.SettingDtlDetails?.filter( + (i) => i.SettingIdName === 'DineIn' + )?.[0]; + }, [preferencedata]); console.log(dailySalesData, 'dailySalesDatadailySalesData', bookings); const bookingTypePreference = @@ -137,12 +173,7 @@ const SalesCountForStandard = ({ const salespagefields = appPreferences?.find( (pref) => pref?.PreferredCatName === 'Sales Page Fields' )?.PreferenceCatDetails; - const AvailableDate = salespagefields?.find( - (type) => - type?.PreferredSubCatName?.toLowerCase() === 'available date' && - type?.PreferredStatus === 'Y' - ); - const { isBulk, setIsBulk } = useDateStore(); + const BookingStatus = useSelector(GlobalBookingStatus); const CheckBookingStatus = BookingStatus?.find((item) => item.ScreenType === 'Booking') @@ -154,7 +185,7 @@ const SalesCountForStandard = ({ item.SettingIdName.toLowerCase() === 'shortcutkeys' && item.SettingValue === 'Y' ); - const sales = GlobalsalesDetailData?.[0] || {}; + const sales = dailySalesData?.[0] || {}; const { DineInOrderCount = 0, TakeAwayOrderCount = 0, @@ -169,41 +200,36 @@ const SalesCountForStandard = ({ SelfDineInAmount = 0, PreOrderAmount = 0, } = sales; - useEffect(() => { - // const { data: res } = await dispatch( - // getPreferenceData({ AppId, CompId, BranchId }) - // ).unwrap(); - const decimalSetting = preferencedata?.[0]?.SettingDtlDetails?.find( - (s) => - s?.SettingIdName?.toLowerCase() === 'decimal' && s?.SettingValue === 'Y' - ); - setAllowDecimal(!!decimalSetting); - let custombillsetting = preferencedata?.[0]?.SettingDtlDetails?.some( - (s) => - s?.SettingIdName?.toLowerCase() === 'customisedbillnumber' && - s?.SettingValue === 'Y' - ); - setCustomisebillno(custombillsetting); + if (preferencedata?.length > 0) { + const decimalSetting = preferencedata?.[0]?.SettingDtlDetails?.find( + (s) => + s?.SettingIdName?.toLowerCase() === 'decimal' && + s?.SettingValue === 'Y' + ); + setAllowDecimal(!!decimalSetting); + let custombillsetting = preferencedata?.[0]?.SettingDtlDetails?.some( + (s) => + s?.SettingIdName?.toLowerCase() === 'customisedbillnumber' && + s?.SettingValue === 'Y' + ); + setCustomisebillno(custombillsetting); - let AutoReceiveStock = preferencedata?.[0]?.SettingDtlDetails?.some( - (s) => - s?.SettingIdName?.toLowerCase() === 'autoreceivestock' && - s?.SettingValue === 'Y' - ); + let AutoReceiveStock = preferencedata?.[0]?.SettingDtlDetails?.some( + (s) => + s?.SettingIdName?.toLowerCase() === 'autoreceivestock' && + s?.SettingValue === 'Y' + ); - setAutoReceiveStock(!AutoReceiveStock); + setAutoReceiveStock(!AutoReceiveStock); + } }, [preferencedata]); - // useEffect(() => { - // if (!selectedDate || (Array.isArray(selectedDate) && selectedDate.length === 0)) { - // setSelectedDate(dayjs()); - // } - // }, [selectedDate, setSelectedDate]); + useEffect(() => { if (AppId && CompId && BranchId && UserId) { fetchBookingStatus(); + getReceivedStock(); } - getReceivedStock(); }, [AppId, CompId, BranchId, UserId]); const getReceivedStock = async () => { @@ -304,24 +330,6 @@ const SalesCountForStandard = ({ width: '120px', }, - // { - // title: 'Product Details', - // dataIndex: 'ProductDetails', - // key: 'ProductDetails', - // width: '120px', - // render: (text, record, index) => ( - // { - - // handleModalOpen(index) - // }} - // > - // - // - // ), - - // }, { title: 'Actions', dataIndex: 'fromBranch', @@ -469,9 +477,7 @@ const SalesCountForStandard = ({ if (isNaN(num)) return allowDecimal ? '0.00' : '0'; return allowDecimal ? num.toFixed(2) : Math.round(num).toString(); }; - const disablePastDates = (current) => { - return current && current < moment().startOf('day'); - }; + const totalTakeAway = TakeAwayAmount + SelfTakeAwayAmount + @@ -534,41 +540,6 @@ const SalesCountForStandard = ({
); - // Fix: Convert string dates to dayjs objects for the DatePicker - const getDatePickerValue = () => { - if (!selectedDate) return isBulk ? [] : null; - console.log(selectedDate, 'selectedDate'); - if (isBulk) { - // For bulk mode, convert string array to dayjs objects array - if (Array.isArray(selectedDate)) { - return selectedDate.map((date) => dayjs(date)); - } - return []; - } else { - // For single date mode, handle both string and dayjs object - if (Array.isArray(selectedDate) && selectedDate.length > 0) { - return dayjs(selectedDate[0]); - } - return dayjs(selectedDate); - } - }; - - const handleDateChange = (dateOrDates) => { - if (isBulk) { - // For bulk mode, convert dayjs objects to string format - const formattedDates = dateOrDates - ? dateOrDates.map((d) => d.format('YYYY-MM-DD')) - : []; - setSelectedDate(formattedDates); - } else { - // For single date mode - if (dateOrDates) { - setSelectedDate(dateOrDates); - } else { - setSelectedDate([]); - } - } - }; const fetchBookingStatus = async () => { let data = { CompId: CompId, @@ -615,735 +586,724 @@ const SalesCountForStandard = ({ const handleInvoiceClose = () => { setListOfInvoices(false); }; - // Table row selection state and handlers - const onSelectChange = (newSelectedRowKeys) => { - setSelectedRowKeys(newSelectedRowKeys); - }; - const handleSubmitSelectedRows = () => { - // TODO: replace this with real submit logic - console.log('Submitting selected rows:', selectedRowKeys); - setIsReceivedModelOpen(false); - setSelectedRowKeys([]); - }; - const rowSelection = { - selectedRowKeys, - onChange: onSelectChange, - }; return ( -
- -
-
- {showSalesTooltip ? ( - - {takeAwayPreference && ( -
-
Takeaway:
-
{TakeAwayOrderCount + SelfTakeAwayOrderCount}
-
- )} - {dinePreference && ( -
-
Dine-in:
-
{DineInOrderCount + SelfDineInOrderCount}
-
- )} + Loading...
}> +
+ +
+
+ {showSalesTooltip ? ( + + {takeAwayPreference && ( +
+
Takeaway:
+
{TakeAwayOrderCount + SelfTakeAwayOrderCount}
+
+ )} + {dinePreference && ( +
+
Dine-in:
+
{DineInOrderCount + SelfDineInOrderCount}
+
+ )} +
+ } + onClick={() => + (OverAllOrderCount || 0) > 0 && setIsModalOpen(true) + } + > + +
+ {isMobile ? 'Count' : 'Sales Count'} : {OverAllOrderCount} +
+ + ) : ( +
+ (OverAllOrderCount || 0) > 0 && setIsModalOpen(true) + } + > + +
+ {isMobile ? 'Count' : 'Sales Count'} : {OverAllOrderCount}
- } - onClick={() => - (OverAllOrderCount || 0) > 0 && setIsModalOpen(true) - } - > - -
- {isMobile ? 'Count' : 'Sales Count'} : {OverAllOrderCount}
- - ) : ( -
- (OverAllOrderCount || 0) > 0 && setIsModalOpen(true) - } - > - -
- {isMobile ? 'Count' : 'Sales Count'} : {OverAllOrderCount} -
-
- )} -
-
- - {/* Rest of your component remains the same */} - {DineInAccess?.SettingValue === 'Y' && - takeAwayPreference && - (TakeAwayOrderCount || SelfTakeAwayOrderCount || PreOrderAmount) > - 0 && ( - -
-
{isMobile ? 'TA' : 'Take Away'} :
-
{`₹ ${safeRound(totalTakeAway)}`}
-
-
- )} - - {DineInAccess?.SettingValue === 'Y' && - dinePreference && - (DineInOrderCount || SelfDineInOrderCount) > 0 && ( - -
-
{isMobile ? 'DI' : 'Dine In'} :
-
{`₹ ${safeRound(totalDineIn)}`}
-
-
- )} - -
-
netAmount > 0 && setIsNetAmtModalOpen(true)} - style={{ cursor: 'pointer' }} - > - -
- {isMobile ? 'NA' : 'Net Amount'} : ₹ {safeRound(netAmount)} + )}
-
- {TableData?.length > 0 && !sportsAppPreference && AutoReceiveStock && ( - - )} - {preferenceshortcutkey && ( -
- + + {/* Rest of your component remains the same */} + {DineInAccess?.SettingValue === 'Y' && + takeAwayPreference && + (TakeAwayOrderCount || SelfTakeAwayOrderCount || PreOrderAmount) > + 0 && ( + +
+
{isMobile ? 'TA' : 'Take Away'} :
+
{`₹ ${safeRound(totalTakeAway)}`}
+
+
+ )} + + {DineInAccess?.SettingValue === 'Y' && + dinePreference && + (DineInOrderCount || SelfDineInOrderCount) > 0 && ( + +
+
{isMobile ? 'DI' : 'Dine In'} :
+
{`₹ ${safeRound(totalDineIn)}`}
+
+
+ )} + +
+
netAmount > 0 && setIsNetAmtModalOpen(true)} + style={{ cursor: 'pointer' }} + > + +
+ {isMobile ? 'NA' : 'Net Amount'} : ₹ {safeRound(netAmount)} +
+
- )} - -
- {Customisebillno && } - {SessionData?.FeatureAddonData?.FeatureDtls?.find( - (item) => item?.FeatureAddonName?.toLowerCase() === 'kiosk sales' - ) && - !sportsAppPreference && ( -
0 && !sportsAppPreference && AutoReceiveStock && ( + + )} + {preferenceshortcutkey && ( +
+ +
+ )} + +
+ {Customisebillno && } + {SessionData?.FeatureAddonData?.FeatureDtls?.find( + (item) => item?.FeatureAddonName?.toLowerCase() === 'kiosk sales' + ) && + !sportsAppPreference && ( +
0 ? 'none' : 'auto', + opacity: OrderStatus > 0 ? 0.5 : 1, + }} + > + {!OtherServicesglobal && ( + + + openModalKiosk()} + style={{ cursor: 'pointer', fontSize: '1.5rem' }} + className="iconsize" + /> + + + )} +
+ )} + {Kioskopen && ( + + )} + + {!OtherServicesglobal && !sportsAppPreference && ( + + {' '} + + + )} + + {!OtherServicesglobal && ( + <> + {CheckBookingStatus == 'Open' ? ( +
+ + {' '} + + +
+ ) : ( +
+ + BookingOpenFun('Open')} + > + + + + + +
+ )} + {!sportsAppPreference && ( +
+ + {''} + + +
+ )} + + )} + + {BookingModalOpen && ( + + )} + {ListOfInvoices && ( + + )} +
+ + {/* Modal with table for multiple bookings */} + + setIsModalOpen(false)} + handleSubmit={() => setIsModalOpen(false)} + width={700} + footer={false} + > +
+ 0 ? 'none' : 'auto', - opacity: OrderStatus > 0 ? 0.5 : 1, + width: '100%', + borderCollapse: 'collapse', + fontFamily: "'Segoe UI', Roboto, sans-serif", + fontSize: '14px', + borderRadius: '8px', + overflow: 'hidden', + boxShadow: '0 2px 8px rgba(0,0,0,0.1)', }} > - {!OtherServicesglobal && ( - - - openModalKiosk()} - style={{ cursor: 'pointer', fontSize: '1.5rem' }} - className="iconsize" - /> - - - )} - - )} - {Kioskopen && ( - - )} - - {!OtherServicesglobal && !sportsAppPreference && ( - - {' '} - - - )} + + + + + + + {/* */} + + + + - {!OtherServicesglobal && ( - <> - {CheckBookingStatus == 'Open' ? ( -
- - {' '} - - {/* */} - -
- ) : ( -
- - BookingOpenFun('Open')} - > - - - - - -
- )} - {!sportsAppPreference && ( -
- - {''} - - -
- )} - - )} - - {BookingModalOpen && ( - - )} - {ListOfInvoices && ( - - )} - - - {/* Modal with table for multiple bookings */} - - setIsModalOpen(false)} - handleSubmit={() => setIsModalOpen(false)} - width={700} - footer={false} - > -
-
+ S.No + + Order ID + + Customer + + Mobile + Booked By + Payment Type + + Amount (₹) +
- - - - - - - {/* */} - - - - - - - {currentData?.length > 0 ? ( - currentData?.map((item, index) => ( - - (e.currentTarget.style.backgroundColor = '#d6e4ff') - } - onMouseLeave={(e) => - (e.currentTarget.style.backgroundColor = - index % 2 === 0 ? '#f7faff' : '#e9f1ff') - } - > - - - - - {/* + {currentData?.length > 0 ? ( + currentData?.map((item, index) => ( + + (e.currentTarget.style.backgroundColor = '#d6e4ff') + } + onMouseLeave={(e) => + (e.currentTarget.style.backgroundColor = + index % 2 === 0 ? '#f7faff' : '#e9f1ff') + } + > + + + + + {/* */} - + + + + )) + ) : ( + - )) - ) : ( - -
- S.No - - Order ID - - Customer - - Mobile - Booked By - Payment Type - - Amount (₹) -
- {startIndex + index + 1} - - {extractLastNumberOrderId(item.OrderId)} - - {item.CustName || '—'} - - {item.CustMobile || '—'} - +
+ {startIndex + index + 1} + + {extractLastNumberOrderId(item.OrderId)} + + {item.CustName || '—'} + + {item.CustMobile || '—'} + {item.BookedBy || "—"} - {item.PaymentTypeName || '—'} - + {item.PaymentTypeName || '—'} + + ₹{item.Amount?.toLocaleString()} +
- ₹{item.Amount?.toLocaleString()} + No booking data available
+
+ + {/* Pagination */} + {totalPages > 1 && ( +
+ {currentPage == 1 ? ( + '' + ) : ( + + )} + + + Page {currentPage} of {totalPages} + - {/* Pagination */} - {totalPages > 1 && ( -
- {currentPage == 1 ? ( - '' - ) : ( - )} +
+ )} +
+ - - Page {currentPage} of {totalPages} - + {/* Modal with table for multiple Net Amt */} - -
- )} -
- - - {/* Modal with table for multiple Net Amt */} - - setIsNetAmtModalOpen(false)} - handleSubmit={() => setIsNetAmtModalOpen(false)} - width={800} - footer={false} - > -
- - - - - - - - - - - - - - - - - - - - - - - - - - {orderDetails?.map((item, index) => { - const total = - (item.CashAmount || 0) + - (item.UpiAmount || 0) + - (item.CardAmount || 0) + - (item.CreditAmount || 0); - - return ( - - (e.currentTarget.style.backgroundColor = '#e6f2ff') - } - onMouseLeave={(e) => - (e.currentTarget.style.backgroundColor = - index % 2 === 0 ? '#f7faff' : '#ffffff') - } + setIsNetAmtModalOpen(false)} + handleSubmit={() => setIsNetAmtModalOpen(false)} + width={800} + footer={false} + > +
+
- Cash - - UPI - - Card - - Credit - - Business UPI - - Total -
- Count - - Amt - - Count - - Amt - - Count - - Amt - - Count - - Amt - - Count - - Amt -
+ + + - - - - - - - - - - - - ); - })} - -
- - {item.CashCount} - - {item.CashAmount} - - {item.UpiCount} - - {item.UpiAmount} - - {item.CardCount} - - {item.CardAmount} - - {item.CreditCount} - - {item.CreditAmount} - - {item.BusinessUpiCount} - - {item.BusinessUpiAmount} - - {total} -
-
-
+ Cash + + + UPI + + + Card + + + Credit + + + Business UPI + + + Total + + + + + Count + + + Amt + + + Count + + + Amt + + + Count + + + Amt + + + Count + + + Amt + + + Count + + + Amt + + + - { - setIsReceivedModelOpen(false); - setSelectedRowKeys([]); - }} - columns={columns} - tableData={TableData} - handlePageChange={handlePageChange} - customTable={false} - /> + + {orderDetails?.map((item, index) => { + const total = + (item.CashAmount || 0) + + (item.UpiAmount || 0) + + (item.CardAmount || 0) + + (item.CreditAmount || 0); - setModalProductDetails(d)} - onSubmit={handleModalSubmit} - /> -
+ return ( + + (e.currentTarget.style.backgroundColor = '#e6f2ff') + } + onMouseLeave={(e) => + (e.currentTarget.style.backgroundColor = + index % 2 === 0 ? '#f7faff' : '#ffffff') + } + > + + {item.CashCount} + + + {item.CashAmount} + + + {item.UpiCount} + + + {item.UpiAmount} + + + {item.CardCount} + + + {item.CardAmount} + + + {item.CreditCount} + + + {item.CreditAmount} + + + {item.BusinessUpiCount} + + + {item.BusinessUpiAmount} + + + {total} + + + ); + })} + + +
+ + + { + setIsReceivedModelOpen(false); + }} + columns={columns} + tableData={TableData} + handlePageChange={handlePageChange} + customTable={false} + /> + + setModalProductDetails(d)} + onSubmit={handleModalSubmit} + /> +
+ ); -}; +}); export default SalesCountForStandard; diff --git a/src/Pages/CancelReschedule/ChangePaymentmode.jsx b/src/Pages/CancelReschedule/ChangePaymentmode.jsx index d5cd450..57a9c38 100644 --- a/src/Pages/CancelReschedule/ChangePaymentmode.jsx +++ b/src/Pages/CancelReschedule/ChangePaymentmode.jsx @@ -14,7 +14,6 @@ import { InputField } from '../../Components/Forms/InputField'; import Buttons from '../../Components/Forms/Buttons'; import { ArrowRightOutlined } from '@ant-design/icons'; import { DropDowns } from '../../Components/Forms/DropDown'; -import { RadioGrpButton } from '../../Components/Forms/RadioGroup.jsx'; import '../../Styles/CancelReschedule/ChangePaymentMode.scss'; import { ChangeSelectedCustDisable, @@ -93,13 +92,14 @@ const ChangePaymentmode = () => { const appPreferences = useSelector(ApplicationPreferences); const commonModulePreference = appPreferences?.find( - (preference) => preference?.PreferredCatName === "Common Module" + (preference) => preference?.PreferredCatName === 'Common Module' )?.PreferenceCatDetails; const sportsAppPreference = commonModulePreference?.find( - (preference) => preference?.PreferredSubCatName === "SportsApp" && preference?.PreferredStatus == 'Y' + (preference) => + preference?.PreferredSubCatName === 'SportsApp' && + preference?.PreferredStatus == 'Y' ); - const [messageType, setMessageType] = useState(null); const [messageData, setMessageData] = useState(null); const [selCancelPay, setselCancelPay] = useState('CR'); @@ -147,11 +147,10 @@ const ChangePaymentmode = () => { name: 'Home', link: `${subDirectory}app-page/home`, }, - { + { name: ' Cancel/Payment Change', link: `${subDirectory}setting/cancel-paymentchange`, }, - ]; useEffect(() => { @@ -212,8 +211,6 @@ const ChangePaymentmode = () => { // third; }; const disabledDate = (current) => current && current > dayjs().endOf('day'); - const disabledFeatureDate = (current) => - current && current < dayjs().endOf('day'); const getCreditcustDetail = async () => { let Credata = { @@ -249,7 +246,7 @@ const ChangePaymentmode = () => { let date; const billormobile = formRef.current?.getFieldsValue()?.[ - selCancelPay === 'CR' ? 'OrderId' : 'PaymodeOrderId' + selCancelPay === 'CR' ? 'OrderId' : 'PaymodeOrderId' ]; if (segmentValue === 'Mobile') { if (selCancelPay === 'CR') { @@ -326,15 +323,13 @@ const ChangePaymentmode = () => { setSalesDetail([]); setFullSalesDetail([]); - if (segmentValue == "Mobile" && billormobile && fromDate && toDate) { + if (segmentValue == 'Mobile' && billormobile && fromDate && toDate) { + setMessageType('error'); + setMessageData(res?.data?.response); + } else { setMessageType('error'); setMessageData(res?.data?.response); } - else { - setMessageType('error'); - setMessageData(res?.data?.response); - } - } setisdisabled(true); }; @@ -384,7 +379,6 @@ const ChangePaymentmode = () => { setFullSalesDetail([]); }; - // Debounce utility const debounce = (func, delay) => { let timer; @@ -442,7 +436,7 @@ const ChangePaymentmode = () => { let date; const billormobile = formRef.current?.getFieldsValue()?.[ - selCancelPay === 'CR' ? 'OrderId' : 'PaymodeOrderId' + selCancelPay === 'CR' ? 'OrderId' : 'PaymodeOrderId' ]; if (segmentValue === 'Mobile') { if (selCancelPay === 'CR') { @@ -781,7 +775,7 @@ const ChangePaymentmode = () => { dispatch(changeSelectedCustId(null)); dispatch(changeSelectedOption({})); dispatch(ChangeSelectedCustDisable(false)); - SelectCanPaymode(null) + SelectCanPaymode(null); } } catch (error) { console.error('Payment mode change failed:', error); @@ -790,8 +784,7 @@ const ChangePaymentmode = () => { if (selCancelPay === 'CR' && selActivityType === 'Cancel') { if (SelCancelType === 'OverAll') { const { NetAmount } = FullSalesDetail?.[0]; - const { ChargeType, ChargesFixed } = - SelCanReason?.[0]; + const { ChargeType, ChargesFixed } = SelCanReason?.[0]; if (ChargeType === 'P') { const temCanCharge = (NetAmount * ChargesFixed) / 100; @@ -804,24 +797,44 @@ const ChangePaymentmode = () => { try { const prodDtl = (FullSalesDetail || [])?.find( (f) => f.OrderId === selectedRowKey - )?.productDetails + )?.productDetails; const SalesId = prodDtl?.[0]?.SalesId; - const ProductDetails = (prodDtl || []).map(({ ProdId, InwardDtlId, Type, SalesQty, Rate, TaxAmt, SinglePc }) => ({ - ProdId, InwardDtlId, Type, Qty: SalesQty, Rate, TotalAmt: SalesQty * Rate, TaxAmt, SinglePc, - })); + const ProductDetails = (prodDtl || []).map( + ({ + ProdId, + InwardDtlId, + Type, + SalesQty, + Rate, + TaxAmt, + SinglePc, + }) => ({ + ProdId, + InwardDtlId, + Type, + Qty: SalesQty, + Rate, + TotalAmt: SalesQty * Rate, + TaxAmt, + SinglePc, + }) + ); if (ProductDetails?.length === 0) { throw new Error('No orders selected'); } - const Amount = ProductDetails.reduce((acc, item) => acc + (item.TotalAmt || 0), 0); + const Amount = ProductDetails.reduce( + (acc, item) => acc + (item.TotalAmt || 0), + 0 + ); const payload = { AppId, CompId, BranchId, SalesId, ProductDetails, - SalesType: "C", + SalesType: 'C', OrderId: selectedRowKey, CreatedBy: UserId, CreatedDate: dayjs()?.format('YYYY-MM-DD'), @@ -829,27 +842,27 @@ const ChangePaymentmode = () => { { PaymentType: SelCanPaymode, Amount, - PaymentStatus: "S" - } - ] + PaymentStatus: 'S', + }, + ], }; const res = await dispatch(PostSalesCancellation(payload)).unwrap(); if (res?.data?.statusCode === 1) { setMessageType('success'); - setMessageData(res?.data?.response || "Posted successfully"); - setSelectedRowKey() - formRef.current?.resetFields() + setMessageData(res?.data?.response || 'Posted successfully'); + setSelectedRowKey(); + formRef.current?.resetFields(); setFullSalesDetail([]); - SelectCanPaymode(null) - setSegmentValue('Bill No') + SelectCanPaymode(null); + setSegmentValue('Bill No'); } else { setMessageType('success'); - setMessageData(res?.data?.response || "Posted successfully"); + setMessageData(res?.data?.response || 'Posted successfully'); } } catch (error) { - setMessageType("error"); - setMessageData(error?.message || "An error occurred"); + setMessageType('error'); + setMessageData(error?.message || 'An error occurred'); } finally { setIsPosting(false); // enable button } @@ -920,7 +933,7 @@ const ChangePaymentmode = () => { const formatted = date?.format('YYYY-MM-DD'); const billormobile = formRef.current?.getFieldsValue()?.[ - selCancelPay === 'CR' ? 'OrderId' : 'PaymodeOrderId' + selCancelPay === 'CR' ? 'OrderId' : 'PaymodeOrderId' ]; let toDate; if (selCancelPay === 'CR') { @@ -930,14 +943,10 @@ const ChangePaymentmode = () => { toDate = formRef.current?.getFieldsValue()?.ReschedulToDate; } } else if (selCancelPay === 'CP') { - toDate = formRef.current?.getFieldsValue()?.["Change- PaymentToDate"]; + toDate = formRef.current?.getFieldsValue()?.['Change- PaymentToDate']; } - if ( - segmentValue === 'Mobile' && - formatted && - toDate !== undefined - ) { + if (segmentValue === 'Mobile' && formatted && toDate !== undefined) { if (billormobile === undefined) { setMessageType('error'); setMessageData('Please enter the mobile number.'); @@ -955,7 +964,7 @@ const ChangePaymentmode = () => { const formatted = date?.format('YYYY-MM-DD'); const billormobile = formRef.current?.getFieldsValue()?.[ - selCancelPay === 'CR' ? 'OrderId' : 'PaymodeOrderId' + selCancelPay === 'CR' ? 'OrderId' : 'PaymodeOrderId' ]; let fromDate; if (selCancelPay === 'CR') { @@ -968,11 +977,7 @@ const ChangePaymentmode = () => { fromDate = formRef.current?.getFieldsValue()?.['Change-PaymentFromDate']; } - if ( - segmentValue === 'Mobile' && - fromDate != undefined && - formatted - ) { + if (segmentValue === 'Mobile' && fromDate != undefined && formatted) { if (billormobile === undefined) { setMessageType('error'); setMessageData('Please enter the mobile number.'); @@ -1107,8 +1112,8 @@ const ChangePaymentmode = () => { {record?.ProdName + (record?.Size ? ' - ' + - record?.Size + - (record?.UomName ? ' - ' + record?.UomName : '') + record?.Size + + (record?.UomName ? ' - ' + record?.UomName : '') : '')} ), @@ -1209,13 +1214,13 @@ const ChangePaymentmode = () => { ...(appPreferences ? [] : [ - { - title: 'BookingType Name', - dataIndex: 'BookingTypeName', - key: 'BookingTypeName', - width: '100px', - }, - ]), + { + title: 'BookingType Name', + dataIndex: 'BookingTypeName', + key: 'BookingTypeName', + width: '100px', + }, + ]), { title: sportsAppPreference ? 'Slot Details' : 'Product Details', dataIndex: 'productDetails', @@ -1340,7 +1345,7 @@ const ChangePaymentmode = () => { display: 'flex', gap: '0.5rem', alignItems: 'center', - flexWrap: "wrap" + flexWrap: 'wrap', }} >
Mode Type :
@@ -1381,8 +1386,6 @@ const ChangePaymentmode = () => { onChange={segmentOnChange} />
*/} - -
{selCancelPay === 'CR' && ( @@ -1423,15 +1426,10 @@ const ChangePaymentmode = () => { gap: '0.5rem', alignItems: 'center', }} - > - - - -
+ >
{selActivityType === 'Cancel' && (
- { alignItems: 'center', gap: '10px', // marginTop: '10px', - flexWrap: 'wrap' + flexWrap: 'wrap', }} > {segmentValue === 'Date' ? ( @@ -1479,17 +1477,23 @@ const ChangePaymentmode = () => { await validateSafeInput(value); // Your existing input sanitization if (!value) { - return Promise.reject(`Please enter ${segmentValue}`); + return Promise.reject( + `Please enter ${segmentValue}` + ); } const digitOnlyRegex = /^[0-9]+$/; if (!digitOnlyRegex.test(value)) { - return Promise.reject(`${segmentValue} should contain digits only`); + return Promise.reject( + `${segmentValue} should contain digits only` + ); } if (segmentValue === 'Bill No') { if (value.length > 30) { - return Promise.reject('Bill No should not exceed 30 characters'); + return Promise.reject( + 'Bill No should not exceed 30 characters' + ); } } @@ -1497,29 +1501,37 @@ const ChangePaymentmode = () => { const mobileRegex = /^[6-9]\d{9}$/; if (!value || value.length !== 10) { - return Promise.reject('Mobile Number must be exactly 10 digits'); + return Promise.reject( + 'Mobile Number must be exactly 10 digits' + ); } if (!mobileRegex.test(value)) { - return Promise.reject('Mobile number must start with 6, 7, 8, or 9'); + return Promise.reject( + 'Mobile number must start with 6, 7, 8, or 9' + ); } await getSalesDetailapi(value); } await getSalesDetailapi(value); return Promise.resolve(); - } - } - + }, + }, ]} > - (e.target.value = e.target.value.replace(/[^0-9]/g, '')) + (e.target.value = e.target.value.replace( + /[^0-9]/g, + '' + )) } label={