diff --git a/src/App.jsx b/src/App.jsx index fca1b6b..0a0c562 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,46 +1,34 @@ -// AppRoutes.jsx -import React, { useEffect, useState, useRef, } from 'react'; +import { useEffect, lazy, Suspense } from 'react'; import { Routes, Route } from 'react-router-dom'; -import { useNavigate } from 'react-router-dom'; -import { useDispatch, useSelector } from 'react-redux'; +import { useSelector } from 'react-redux'; import ProtectedRoutes from './ProtectedRoutes'; -import SelfBooking from './Pages/SelfBooking/SelfBooking.jsx' -import { isMobile, isIOS } from "react-device-detect"; -// const { routesConfig }=lazy(()=>import('./routesConfig')); +import SelfBooking from './Pages/SelfBooking/SelfBooking.jsx'; +import { isMobile, isIOS } from 'react-device-detect'; import { routesConfig } from './routesConfig'; -import { - ChangeAppExpDateData, - changeHeightforExpDate, - getAppSubscriptionDate, - GlobalItemCard, -} from './Features/BookingScreen/BookingData/BookingData.js'; -import { - checkSession, - GenerateLogout, -} from './Features/BrachLogin/BranchLogin.js'; -import { - clearSession, - getSession, - TokendecryptedValuesFun, -} from './Services/Others.js'; +import { GlobalItemCard } from './Features/BookingScreen/BookingData/BookingData.js'; +import { clearSession, getSession } from './Services/Others.js'; import devtools from 'devtools-detect'; -import KisokSelBooking from './Pages/SelfBooking/KisokSelBooking.jsx'; -import IndividualBooking from './Pages/SelfBooking/IndividualBooking.jsx'; +const KisokSelBooking = lazy( + () => import('./Pages/SelfBooking/KisokSelBooking') +); + +const IndividualBooking = lazy( + () => import('./Pages/SelfBooking/IndividualBooking') +); const commonSubDir = import.meta.env.ENV_COMMON_BASE_URL; const subDirectory = import.meta.env.ENV_BASE_URL; -import "../ownLib/my-ui-lib.css" +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'; const AppRoutes = () => { - const navigate = useNavigate(); - const dispatch = useDispatch(); const ItemCard = useSelector(GlobalItemCard); - const [remainingDays, setRemainingDays] = useState(null); - const prevRemainingDays = useRef(null); - const [sessionData, setSessionData] = useState(null); - const [devToolsOpen, setDevToolsOpen] = useState(false); + // const { sessionData, logout } = useSessionManager(ItemCard); + // useSubscriptionManager(sessionData, logout); + useEffect(() => { - const handlePopState = (e) => { + const handlePopState = () => { const SessionId = getSession('SessionId'); if (!SessionId) { alert( @@ -62,203 +50,48 @@ const AppRoutes = () => { }; }, []); - //cmd it start - // useEffect(() => { - // sessionCheckFun() - // }, [navigate, ItemCard]); - - //cmd it End - - useEffect(() => { - const loadSessionData = () => { - const CompId = getSession('CompId'); - const AppId = getSession('AppId'); - const BranchId = getSession('BranchId'); - const UserType = getSession('UserType'); - console.log('loadSessionData:', CompId, AppId, BranchId, UserType); - - if (CompId && AppId && BranchId) { - setSessionData({ CompId, AppId, BranchId, UserType }); - return true; // Indicate that session data is available + if (isMobile || isIOS) return; + const timer = setInterval(() => { + if (devtools.isOpen) { + document.body.innerHTML = + "

Close Inspect to continue

"; } - return false; // Indicate that session data is not yet available - }; + }, 1000); - if (!loadSessionData()) { - const interval = setInterval(() => { - if (loadSessionData()) { - clearInterval(interval); // Stop checking once data is available - } - }, 1000); - - return () => clearInterval(interval); // Cleanup interval on unmount - } + return () => clearInterval(timer); }, []); - useEffect(() => { - const fetchExpDate = async () => { - if (!sessionData) { - console.log('Session data not available, skipping API call...'); - return; - } - - try { - const { CompId, AppId, BranchId, UserType } = sessionData; - const data = { CompId, BranchId, AppId }; - - let res = await dispatch(getAppSubscriptionDate(data)).unwrap(); - - if (res?.data?.statusCode === 1 && res?.data?.data?.length > 0) { - const expData = res?.data?.data?.[0]; - - if (prevRemainingDays.current !== expData.RemainingDays) { - prevRemainingDays.current = expData.RemainingDays; - setRemainingDays(expData.RemainingDays); - dispatch(ChangeAppExpDateData(expData)); - dispatch(changeHeightforExpDate(expData.RemainingDays)); - - if ( - expData.RemainingDays < 1 && - expData.RemainingHours < 1 && - expData.RemainingMinutes < 1 && - expData.RemainingSeconds < 1 - ) { - if ( - UserType !== 'Super Admin' || - UserType !== 'Super Admin User' - ) { - console.log('Subscription expired, logging out...'); - alert( - 'Subscription expired, logging out. Redirecting to login...' - ); - Logout(); - } - } - } - } else { - console.log('No subscription data found, logging out...'); - alert( - 'No subscription data found, logging out. Redirecting to login...' - ); - Logout(); - } - } catch (error) { - console.error('Error fetching subscription data:', error); - } - }; - - if (remainingDays === null) { - fetchExpDate(); - } - - const interval = setInterval(fetchExpDate, 60 * 60 * 1000); - - return () => clearInterval(interval); - }, [sessionData, remainingDays]); - - const Logout = async () => { - const UserId = getSession('UserId'); - const status = 'N'; - try { - const res = await dispatch(GenerateLogout({ UserId, status })).unwrap(); - if (res?.data?.statusCode === 1) { - sessionStorage.clear(); - window.location.replace(`${commonSubDir}`); - } - } catch (error) { - console.error('Logout failed:', error); - } - }; - // mohan - // useEffect(() => { - // if (isMobile || isIOS) { - // console.log("📱 Mobile/iOS device → skipping DevTools detection"); - // return; - // } - // const checkDevTools = setInterval(() => { - // if (devtools.isOpen && !devToolsOpen) { - // setDevToolsOpen(true); - // document.body.innerHTML = - // "

Close Inspect to continue using the application.

"; - // } - // else if (!devtools.isOpen && devToolsOpen) { - // setDevToolsOpen(false); - - // setTimeout(() => { - // window.location.reload(); - // }, 100); - - // clearInterval(checkDevTools); - // } - - // if (!devtools.isOpen) { - // let before = performance.now(); - - // let after = performance.now(); - - // let executionDelay = after - before; - - // if (executionDelay > 100) { - // setDevToolsOpen(true); - // document.body.innerHTML = - // "

Close Inspect to continue using the application.

"; - // } else { - // setDevToolsOpen(false); - // } - // } - // }, 1000); - - // return () => clearInterval(checkDevTools); - // }, [devToolsOpen]); - - const sessionCheckFun = async () => { - const UserId = getSession('UserId'); - const sessionId = getSession('SessionId'); - const IsLogout = getSession('Mode'); - let encryptedLoginType = TokendecryptedValuesFun( - sessionStorage.getItem('LoginType') - ); - if (encryptedLoginType != 'Kiosk') { - const res = await dispatch(checkSession({ UserId, sessionId })).unwrap(); - if (res?.data?.statusCode === 1) { - if (res?.data?.response === 'False') { - if (IsLogout !== 'Logout') { - alert('Session invalid. Redirecting to login...'); - } - clearSession(); - window.location.replace(commonSubDir); - } - } - } - }; - return ( - - } - /> - } - /> + Loading…}> + } - /> - } /> - - } - /> - } - /> - + path={`${subDirectory}selfBooking/:SelfBookingId`} + element={} + /> + } + /> + } + /> + } + /> + } + /> + } + /> + + ); }; diff --git a/src/AuthContext.jsx b/src/AuthContext.jsx index 94bcb3a..825ee8b 100644 --- a/src/AuthContext.jsx +++ b/src/AuthContext.jsx @@ -1,5 +1,5 @@ // AuthContext.jsx -import React, { createContext, useContext, useState, useEffect } from 'react'; +import { createContext, useContext, useState, useEffect } from 'react'; import { useDispatch } from 'react-redux'; import { getSession } from './Services/Others'; import { @@ -64,7 +64,8 @@ export const AuthProvider = ({ children }) => { ); setAdvance(hasAdvance); const hasProOrAdvance = - hasAdvance || pricingData.some((item) => item.PricingName === 'Customized'); + hasAdvance || + pricingData.some((item) => item.PricingName === 'Customized'); setProORAdvance(hasProOrAdvance); } catch (error) { console.error('Error fetching pricing name:', error); diff --git a/src/Components/Menu/SideMenu.jsx b/src/Components/Menu/SideMenu.jsx index 095fafc..5f6adf2 100644 --- a/src/Components/Menu/SideMenu.jsx +++ b/src/Components/Menu/SideMenu.jsx @@ -5,7 +5,6 @@ import { Menu } from 'antd'; import { changePreviewComponents, changeSelectedPrintdummyData, - getTemplate, } from '../../Features/ThemeChange/ThemeChange'; import { changeBookingType, @@ -69,9 +68,6 @@ const SideMenu = ({ mode, theme, items }) => { const [clickedKeys, setClickedKeys] = useState([]); const dispatch = useDispatch(); const navigate = useNavigate(); - const CompId = getSession('CompId'); - const BranchId = getSession('BranchId'); - const AppId = getSession('AppId'); const DineinDefault = useSelector(GlobalDineinDefault); const handleMouseEnter = (e) => { @@ -187,28 +183,7 @@ const SideMenu = ({ mode, theme, items }) => { if (e == `${subDirectory}saleslayouts/print-selection`) { dispatch(changeSelectedPrintdummyData(true)); } - // if(e==`${subDirectory}kiosksales`){ - // const elem = document.documentElement; - // if (elem.requestFullscreen) { - // elem.requestFullscreen(); - // } else if (elem.mozRequestFullScreen) { // Firefox - // elem.mozRequestFullScreen(); - // } else if (elem.webkitRequestFullscreen) { // Chrome, Safari and Opera - // elem.webkitRequestFullscreen(); - // } else if (elem.msRequestFullscreen) { // IE/Edge - // elem.msRequestFullscreen(); - // } - // }else{ - // if (document.exitFullscreen) { - // document.exitFullscreen(); - // } else if (document.mozCancelFullScreen) { // Firefox - // document.mozCancelFullScreen(); - // } else if (document.webkitExitFullscreen) { // Chrome, Safari and Opera - // document.webkitExitFullscreen(); - // } else if (document.msExitFullscreen) { // IE/Edge - // document.msExitFullscreen(); - // } - // } + navigate(e); } catch (error) { diff --git a/src/Components/Menu/SideMenuPozo.jsx b/src/Components/Menu/SideMenuPozo.jsx index bbd38dd..1856fd9 100644 --- a/src/Components/Menu/SideMenuPozo.jsx +++ b/src/Components/Menu/SideMenuPozo.jsx @@ -1,45 +1,15 @@ -import React, { useState, useEffect, useRef } from 'react'; +import { useState, useEffect, useRef } from 'react'; import { useNavigate, useLocation } from 'react-router-dom'; import { useSelector } from 'react-redux'; -import { - FaBars, - FaThLarge, - FaHome, - FaCog, - FaChartBar, - FaFileAlt, - FaMobileAlt, - FaSignOutAlt, - FaSignInAlt, - FaArrowRight, - FaCaretRight, -} from 'react-icons/fa'; -import { - MdSettings, - MdOutlineReport, - MdOutlineHome, - MdOutlineKeyboardArrowDown, - MdOutlineKeyboardArrowRight, -} from 'react-icons/md'; -import { BiLogOut, BiLogIn } from 'react-icons/bi'; -import { - AiOutlineAppstore, - AiOutlineSetting, - AiOutlineBarChart, - AiOutlineFileText, -} from 'react-icons/ai'; -import { GiHamburgerMenu } from 'react-icons/gi'; + import './SideMenuPozo.scss'; -import { FaCaretDown } from 'react-icons/fa'; import { useDispatch } from 'react-redux'; import { useContext } from 'react'; import { AuthContext } from '../../AuthContext'; import PozoMenu from './PozoMenu'; -import { getSession } from '../../Services/Others'; import { changePreviewComponents, - changeSelectedPrintdummyData, - getTemplate, + changeSelectedPrintdummyData } from '../../Features/ThemeChange/ThemeChange'; import { changeBookingType, @@ -67,7 +37,7 @@ import { import { ChangeTotalAmount } from '../../Features/ExteraCharges/ExtraCharges'; import * as Offer from '../../Features/Offer/Offer'; import { FiMenu } from 'react-icons/fi'; -import POZOMIND from '../../Images/PozomindWLogo.png'; + import { ChangeFullFreeProductList, changeFullOfferAppliedProducts, @@ -165,9 +135,7 @@ const SideMenuPozo = ({ items = [] }) => { const [collapsed, setCollapsed] = useState(window.innerWidth < 768); const [dropdownPosition, setDropdownPosition] = useState({}); const menuRef = useRef(); - const CompId = getSession('CompId'); - const BranchId = getSession('BranchId'); - const AppId = getSession('AppId'); + const DineinDefault = useSelector(GlobalDineinDefault); const [collapse, setCollapse] = useState(false); @@ -381,57 +349,7 @@ const SideMenuPozo = ({ items = [] }) => { (item) => !bottomKeys.includes(item.label) ); // Recursive render for menu and submenus - const renderMenuItems = (items, parentKeys = [], level = 0) => ( -
0 ? ' nested-list' : ''}`}> - {(items || []).filter(Boolean).map((item) => ( -
-
0 ? 'dropdown-submenu-item' : 'menu-item'}${isSelected(item.key) || (level === 0 && hasSelectedChild(item)) ? ' selecteded' : ''}${isOpen(item.key) ? ' open' : ''}${item.children ? ' has-children' : ''}`} - onClick={(e) => { - e.stopPropagation(); - handleMenuClick(item, parentKeys, e, level); - }} - // style={{ paddingLeft: `${level * 10 + 1}px` }} - > - {item.icon && level === 0 && ( - - {item.icon} - - )} - {!collapse && {item.label}} - {!collapse && ( - - {isDropdownItemSelected(item) ? '●' : ''} - - )} - {item.children && !collapse && ( - - {level === 0 ? ( - - ) : ( - - )} - - )} -
- {item.children && isOpen(item.key) && !collapse && ( -
0 ? ' nested' : ''}`}> - {renderMenuItems( - item.children, - [...parentKeys, item.key], - level + 1 - )} -
- )} -
- ))} -
- ); + // Custom onClick handler for PozoMenu const handlePozoMenuClick = (e) => { diff --git a/src/Pages/BookingScreen/Components/BSItemCards/BsBookingitemCard.jsx b/src/Pages/BookingScreen/Components/BSItemCards/BsBookingitemCard.jsx index cd14777..2755054 100644 --- a/src/Pages/BookingScreen/Components/BSItemCards/BsBookingitemCard.jsx +++ b/src/Pages/BookingScreen/Components/BSItemCards/BsBookingitemCard.jsx @@ -1,19 +1,15 @@ import React, { useCallback, useEffect, useRef, useState } from 'react'; import { shallowEqual, useDispatch, useSelector } from 'react-redux'; -import moment from 'moment'; -import { App, Badge, DatePicker, Modal, Tooltip, Form, message } from 'antd'; -import { GoTriangleRight } from 'react-icons/go'; +import { Badge, DatePicker, Modal, Tooltip, message } from 'antd'; import { ExclamationCircleOutlined, PlusOutlined } from '@ant-design/icons'; import defaultimage from '../../../../Images/defaultItemImg.png'; import FormHeader from '../../../PageComponents/FormHeader'; import { - GlobalPricingAppPricingName, SelectedGlobalCardColorDetail, SelectedGlobalCardFont, StoredSessionData, getTemplateData, } from '../../../../Features/ThemeChange/ThemeChange'; -import { Tables } from '../../../../Components/Tables/Table'; import { GlobalProductSubCategorie, GlobalItemCard, @@ -107,26 +103,13 @@ import { v4 as uuidv4 } from 'uuid'; // Dummy SortableCard component import { useSortable } from '@dnd-kit/sortable'; import { CSS } from '@dnd-kit/utilities'; -import HuggingFaceVoiceForm from '../../../VoiceToText/VoiceToText.jsx'; import VoiceToTextItemCard from '../../../VoiceToText/VoiceToTextItemCard.jsx'; import { ExtractDateFormate } from '../../../../Services/Others.js'; import { - changeFreeProductForLoyalty, - ChangeFreeProductList, - ChangeFullFreeProductList, changeFullOfferAppliedProducts, - ChangeOfferAppliedProducts, - changeOfferAppliedProductsForLoyalty, changeOfferAppliedProductsForMembership, - changeTriggerOfferFree, - getOfferinBooking, - GlobalFreeProdList, - GlobalOfferAppliedProducts, - GlobalOverAllOfferAmt, - GlobalTriggerOfferFree, - RemoveOfferAppliedProduct, + GlobalOfferAppliedProducts } from '../../../../Features/Offer/Offernew/BookingOffernew.js'; -import { validateOffers } from './ValidateOffer.jsx'; import { useSaleswiseOfferWatcher } from './SalesWiseOffer.jsx'; import { ApplicationPreferences } from '../../../../Features/BrachLogin/BranchLogin.js'; import { useDateStore } from '../../../../Features/BookingScreen/BookingData/DateStore.js'; @@ -137,10 +120,7 @@ import dayjs from 'dayjs'; import BSCustomerSelect from '../UtillComponents/BSSelectCustomer.jsx'; import BSNavBarAddUser from '../UtillComponents/BSNavBarAddUser.jsx'; import { FaAngleLeft, FaAngleRight } from 'react-icons/fa'; - import useRemoveFromCart from './RemoveFromCartFunction.jsx'; - -import { IoIosAdd } from 'react-icons/io'; import { LuMinus } from 'react-icons/lu'; import BranchName from '../../Template/BranchName.jsx'; import { FiPlus } from 'react-icons/fi'; @@ -179,7 +159,7 @@ export function SortableCard({ id, children, item }) { ); } -const { RangePicker } = DatePicker; + const BsBookingitemCard = (props) => { const voiceTriggerRef = useRef(null); const unsubscribeRef = useRef(null); @@ -191,14 +171,10 @@ const BsBookingitemCard = (props) => { const handleDecline = async (item) => { await decline(item, setPreviousdataLength); }; - const handleClearAll = async () => { - await clearAllItems(); - }; - const Clearall = async () => { - await handleClearAll(); - }; - const [form] = Form.useForm(); + + + const cardFunction = props?.cardFunctionality; // const applyOffer = useApplyOfferto_CardDetail(); const preferenceDatas = useSelector(PreferenceData, shallowEqual); diff --git a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/OtherServicePrintStyle1.jsx b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/OtherServicePrintStyle1.jsx index 20b63d1..7559f21 100644 --- a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/OtherServicePrintStyle1.jsx +++ b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/OtherServicePrintStyle1.jsx @@ -1,120 +1,47 @@ -import React from "react"; + import { useDispatch, useSelector } from "react-redux"; import { - dateFormatChange1, - extractLastNumber, - extractLastNumberOrderId, + dateFormatChange1 } from "../../../../Services/Others"; import { - GlobalprintSlNo, - GlobalprintItem, - GlobalprintMRP, - GlobalprintDiscount, - GlobalprintQuantity, - GlobalprintRate, - GlobalprintAmount, - GlobalprintHsnCode, - GlobalprintQrcodet, GlobalPritdummyData, changeReprintDataFound, - GloabalFieldDetails, - GlobalprintSignature, - GlobalprinttermsAndConditions, - GlobalSignatureImage, - Globalnotes, - GlobalthemeFormat, - GlobalBillName, } from "../../../../Features/ThemeChange/ThemeChange"; import "../../../../Styles/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle1.scss"; import QRCode from "react-qr-code"; -import { GlobalUpiIDprint } from "../../../../Features/BookingScreen/BookingData/BookingData"; -import signature from "../../../../Images/signatureimage.jpg" import { ApplicationPreferences } from "../../../../Features/BrachLogin/BranchLogin"; const OtherServicePrintStyle1 = ({ - index, - totalQuantityFilter, - Date1, - CashierName, - totalQuantity, - OrderDetailGST, - OrderDetailIGST, - OrderDetailVAT, + table2Data, - UpiId, PaymentStatus, - PrintLogo, - PrintGreeting, printDatas, }) => { const dispatch = useDispatch(); - const GlobalUpiID = useSelector(GlobalUpiIDprint); - const FieldDetails = useSelector(GloabalFieldDetails); - const SLNO = FieldDetails?.["Sl.No"]; - const Item = FieldDetails?.["Item"]; - const MRP = FieldDetails?.["MRP"]; - const Discount = FieldDetails?.["Discount"]; - const Quantity = FieldDetails?.["Quantity"]; - const Rate = FieldDetails?.["Rate"]; - const Amount = FieldDetails?.["Amount"]; - const HsnCode = FieldDetails?.["HsnCode"]; - const Qrcodet = FieldDetails?.["Qrcode"]; - const GlobalSlNo = useSelector(GlobalprintSlNo); - const GlobalItem = useSelector(GlobalprintItem); - const GlobalMRP = useSelector(GlobalprintMRP); - const GlobalDiscount = useSelector(GlobalprintDiscount); - const GlobalQuantity = useSelector(GlobalprintQuantity); - const GlobalRate = useSelector(GlobalprintRate); - const GlobalAmount = useSelector(GlobalprintAmount); - const GlobalHsnCode = useSelector(GlobalprintHsnCode); - const GlobalQrcodet = useSelector(GlobalprintQrcodet); + const GlobaldummyData = useSelector(GlobalPritdummyData); - const GlobalSignature = useSelector(GlobalprintSignature); - const GlobaltermsAndConditions = useSelector(GlobalprinttermsAndConditions); - const GlobalSignatureImages = useSelector(GlobalSignatureImage); - const GlobalIsnotes = useSelector(Globalnotes); - const GlobalthemeFormatr = useSelector(GlobalthemeFormat) - const GlobalBilltext = useSelector(GlobalBillName) + 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 keysLength = Object.keys(table2Data ?? {}).length; - let TermsAndConditions = printDatas?.TermsandConditions - let SignatureImg = printDatas?.Signature - let Notestext = printDatas?.Notes - let BillName = printDatas?.PrintHdrName + let FormatTheme = printDatas?.PrintType == "S" ? true : false let PageSize = printDatas?.PageSize - const Signature = FieldDetails?.["signature"]; - const TermsnAdCondition = FieldDetails?.["terms&conditions"]; + console.log("table2Datatable2Datatable2Datatable2Data", table2Data,table2Data?.[0]?.BranchName ); if (keysLength > 0) { dispatch(changeReprintDataFound(true)); } - const currentDate = new Date(); - const day = currentDate.getDate().toString().padStart(2, "0"); - const monthNames = [ - "Jan", - "Feb", - "Mar", - "Apr", - "May", - "Jun", - "Jul", - "Aug", - "Sep", - "Oct", - "Nov", - "Dec", - ]; - const monthIndex = currentDate.getMonth(); - const year = currentDate.getFullYear().toString().slice(-2); + + + const formattedDate =dateFormatChange1(table2Data?.[0]?.CreatedDate); // `${day}-${monthNames[monthIndex]}-${year}`; @@ -125,37 +52,13 @@ console.log("table2Datatable2Datatable2Datatable2Data", table2Data,table2Data?.[ const DineInData = table2Data?.productDetails?.filter( (item) => item.BookingTypeName?.toLowerCase() === "dine in" ); - let PaymentStatusSuccess = PaymentStatus?.filter( - (ps) => ps.PaymentStatus === "S" - ); - const TakeawayTotal = TakeawayData?.reduce( - (accumulator, currentValue) => accumulator + currentValue.TotalAmt, - 0 - ); - const DineInTotal = DineInData?.reduce( - (accumulator, currentValue) => accumulator + currentValue.TotalAmt, - 0 - ); - const aggregatedPayments = PaymentStatusSuccess?.reduce( - (acc, paymentdata) => { - const paymentType = paymentdata?.PaymentTypeName; - const amount = Number(paymentdata?.Amount); - if (acc[paymentType]) { - acc[paymentType] += amount; - } else { - acc[paymentType] = amount; - } - return acc; - }, - {} - ); - const productsData = table2Data?.productDetails || []; + const offers = table2Data?.OrderOfferDetails || []; - let TotalOfferAmount = 0; + // Calculate SalesWiseOffers total amount offers.forEach(offer => { @@ -163,19 +66,9 @@ console.log("table2Datatable2Datatable2Datatable2Data", table2Data,table2Data?.[ TotalOfferAmount += offer.OfferAmount; } }); - const hasMappedOffer = offers.some(offer => - ["ItemWiseOffers", "BundleOffers", "QuantityWiseOffers"].includes(offer.TableName) - ); + - if (hasMappedOffer) { - - const productTotal = productsData?.reduce((acc, item) => acc + (item?.Type != "C" ? item.OfferAmt : item.OfferValue || 0), 0); - TotalOfferAmount += productTotal; - } else { - const Combothere = productsData?.filter(item => item?.Type == "C") - const CombothereTotal = Combothere?.reduce((acc, item) => acc + (item.OfferValue || 0), 0); - TotalOfferAmount += CombothereTotal; - } + const products = [ diff --git a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle1.jsx b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle1.jsx index 4ff7674..36b226a 100644 --- a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle1.jsx +++ b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle1.jsx @@ -40,7 +40,6 @@ import { } from '../../../../Features/BookingScreen/BookingData/BookingData'; import signature from '../../../../Images/signatureimage.jpg'; import { ApplicationPreferences } from '../../../../Features/BrachLogin/BranchLogin'; -import { settingDataSelector } from '../../../../Features/PreferenceMaster/PreferenceMaster'; import Logo from '../../../../Images/Logo.jpg'; const PrintStyle1 = ({ index, diff --git a/src/Pages/DashBoard/Chart/GraphChart.jsx b/src/Pages/DashBoard/Chart/GraphChart.jsx index 73eec74..96e2875 100644 --- a/src/Pages/DashBoard/Chart/GraphChart.jsx +++ b/src/Pages/DashBoard/Chart/GraphChart.jsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react'; +import { useState, useEffect } from 'react'; import { Tooltip } from 'antd'; import './GraphChart.scss'; // For styling import TooltipWrapper from '../../../Components/Tooltip/Tooltip'; @@ -206,36 +206,7 @@ const GraphChart = ({ datasets }) => { .join(' '); }; - // const renderDots = (data, color) => { - // const maxValue = Math.max(...data.map(item => item.value)); - // const svgHeight = 200; - // const svgWidth = 400; - // const gap = svgWidth / (data.length - 1); - // return data.map((point, index) => { - // const x = index * gap; - // const y = svgHeight - (point.value / maxValue) * svgHeight; - - // return ( - // - // handleMouseOver(e, point)} - // onMouseOut={handleMouseOut} - // /> - // - // {formatValue(point.value)} ({item.date}) - // - // - // ); - // }); - // }; const renderDots = (data, color) => { const reversedData = [...data].reverse(); @@ -507,7 +478,7 @@ const GraphChart = ({ datasets }) => {
- {Array.from({ length: 7 }, (_, i) => { + {Array.from({ length: 8 }, (_, i) => { const date = new Date(); date.setDate(date.getDate() - i); return ( diff --git a/src/Pages/DashBoard/Chart/GraphChart.scss b/src/Pages/DashBoard/Chart/GraphChart.scss index f38181c..68680bd 100644 --- a/src/Pages/DashBoard/Chart/GraphChart.scss +++ b/src/Pages/DashBoard/Chart/GraphChart.scss @@ -73,7 +73,7 @@ width: inherit; margin-top: 10px; .labelss { - font-size: 11px; + font-size: 10px; font-family: 'Poppins'; color: #000000; font-weight: 400; diff --git a/src/Pages/DashBoard/PieChart.jsx b/src/Pages/DashBoard/PieChart.jsx index 781822a..3a2d650 100644 --- a/src/Pages/DashBoard/PieChart.jsx +++ b/src/Pages/DashBoard/PieChart.jsx @@ -1,93 +1,4 @@ -// import React, { useEffect, useRef, useState } from 'react'; -// import Highcharts from 'highcharts'; -// import HighchartsReact from 'highcharts-react-official'; -// import "./PieChart.scss" -// const DynamicPieChart = ({ chartData }) => { -// const [overallValue, setOverallValue] = useState(0); -// const chartRef = useRef(); - -// useEffect(() => { -// if (chartRef.current && chartData) { -// const chart = chartRef.current.chart; -// chart.series[0].setData(chartData); -// const sum = chartData.reduce((total, dataPoint) => total + dataPoint.y, 0); -// setOverallValue(sum); - -// // Update the chart title to include the overall value -// chart.setTitle({ text: `Overall Amount: ${sum}` }); -// } -// }, [chartData]); - -// return ( -//
-// -//
-// ); -// }; - -// export default DynamicPieChart; - -// import React, { useEffect, useRef, useState } from 'react'; -// import Highcharts from 'highcharts'; -// import HighchartsReact from 'highcharts-react-official'; -// import "./PieChart.scss" -// const DynamicPieChart = ({ chartData }) => { -// const [overallValue, setOverallValue] = useState(0); -// const chartRef = useRef(); - -// useEffect(() => { -// if (chartRef.current && chartData) { -// const chart = chartRef.current.chart; -// chart.series[0].setData(chartData); -// const sum = chartData.reduce((total, dataPoint) => total + dataPoint.y, 0); -// setOverallValue(sum); - -// // Update the chart title to include the overall value -// chart.setTitle({ text: `Overall Amount: ${sum}` }); -// } -// }, [chartData]); - -// return ( -//
-// -//
-// ); -// }; - -// export default DynamicPieChart; - -// create by sree -import React, { useMemo } from 'react'; +import { useMemo } from 'react'; import Highcharts from 'highcharts'; import HighchartsReact from 'highcharts-react-official'; import './PieChart.scss'; @@ -105,16 +16,25 @@ const DynamicPieChart = ({ chartData }) => { ); if (!chartData?.length) { - return
No Data Found
; + return ( +
+ No Data Found +
+ ); } return ( diff --git a/src/Pages/DashBoard/RetailDashboard.jsx b/src/Pages/DashBoard/RetailDashboard.jsx index f677240..b38fb69 100644 --- a/src/Pages/DashBoard/RetailDashboard.jsx +++ b/src/Pages/DashBoard/RetailDashboard.jsx @@ -1,28 +1,26 @@ -import React, { useCallback, useEffect, useRef, useState } from 'react'; -import '../../Styles/DashBoard/RetailDashBoard.scss'; -import GraphChart from './Chart/GraphChart'; -import { DatePicker, Space, Tooltip } from 'antd'; -import dayjs from 'dayjs'; -import { IoMdRefresh } from 'react-icons/io'; -import { CiShop } from 'react-icons/ci'; -import { FiMenu } from 'react-icons/fi'; -import PozoMind from '../../Images/pozologowhite.svg'; +import { useCallback, useEffect, useRef, useState,lazy, Suspense } from 'react'; import { useNavigate, useOutletContext } from 'react-router-dom'; -import CalendarDropdown from '../../Components/CalendarDropdown'; -import { MdKeyboardArrowDown } from 'react-icons/md'; -import { IoMdNotificationsOutline } from 'react-icons/io'; -import { - getdashboard, - getdashboarddate, - getpreOrderDashBoard, - getSalesHdr, - getTopSellingCustomers, -} from '../../Features/RetailDashboard/Dashboard.js'; -import { FaTimesCircle } from 'react-icons/fa'; +import { shallowEqual, useDispatch } from 'react-redux'; +import { useSelector } from 'react-redux'; + +import { DatePicker, Tooltip } from 'antd'; +import dayjs from 'dayjs'; + +import '../../Styles/DashBoard/RetailDashBoard.scss'; + +const GraphChart = lazy(() => import('./Chart/GraphChart')); +const TopSellingProductsChart = lazy( + () => import('./TopSellingProductsChart.jsx') +); + import sandClock from '../../Images/sandClock.png'; +import Add from '../../Images/dashboard/Add.png'; +import AddPurchase from '../../Images/dashboard/AddPurchase.png'; +import invoice from '../../Images/dashboard/invoice.png'; +import user from '../../Images/dashboard/user.jpg'; +import report from '../../Images/dashboard/report.png'; + import { - FeatureAddon, - getTemplate, GlobalPricingAppPricingName, StoredSessionData, } from '../../Features/ThemeChange/ThemeChange.js'; @@ -31,15 +29,20 @@ import { getAppSubscriptionDate, getPreferenceData, } from '../../Features/BookingScreen/BookingData/BookingData.js'; +import { + getdashboard, + getdashboarddate, + getpreOrderDashBoard, + getSalesHdr, + getTopSellingCustomers, +} from '../../Features/RetailDashboard/Dashboard.js'; import { clearSession, - dateFormatChange, encryptedValuesUrlFun, ExtractDateFormate, getSession, } from '../../Services/Others'; -import { shallowEqual, useDispatch } from 'react-redux'; -import { useSelector } from 'react-redux'; + import { getAllprodIds, getExpireProductsList, @@ -58,28 +61,36 @@ import { PUTLoginuser, } from '../../Features/BrachLogin/BranchLogin.js'; import { getPurchasedAppDetails } from '../../Features/BookingScreen/Pricing/Pricing.js'; -import Add from '../../Images/dashboard/Add.png'; -import AddPurchase from '../../Images/dashboard/AddPurchase.png'; -import invoice from '../../Images/dashboard/invoice.png'; -import user from '../../Images/dashboard/user.jpg'; -import report from '../../Images/dashboard/report.png'; -import Calendar from '../../Components/Calendar/Calendar'; -import { PiSignOut } from 'react-icons/pi'; -import BSNavBarUserInfo from '../BookingScreen/Components/BSNavbar/BSNavBarUserInfo'; -import { DefaultModal } from '../../Components/Modal/DefaultModal'; -import { RadioGrpButton } from '../../Components/Forms/RadioGroup.jsx'; -import { DropDowns } from '../../Components/Forms/DropDown.jsx'; + +const BSNavBarUserInfo = lazy(() => + import('../BookingScreen/Components/BSNavbar/BSNavBarUserInfo') +); +const DefaultModal = lazy(() => + import('../../Components/Modal/DefaultModal').then((m) => ({ + default: m.DefaultModal, + })) +); + +const RadioGrpButton = lazy(() => + import('../../Components/Forms/RadioGroup.jsx').then((m) => ({ + default: m.RadioGrpButton, + })) +); + +const DropDowns = lazy(() => + import('../../Components/Forms/DropDown.jsx').then((m) => ({ + default: m.DropDowns, + })) +); import { ChangeRedirectStatus, getEmpAccess, GlobalRedirectStatus, } from '../../Features/AppPage/CenterPage.js'; import { UserDataBasedOnBranchId } from '../../Features/Reports/Reports.js'; -import { gettableData } from '../../Features/PreferenceMaster/PreferenceMaster.js'; import Loader from '../../Components/Loader/Loader.jsx'; import { getUserProfile } from '../../Features/UserAccount/userData.js'; -import TopSellingProductsChart from './TopSellingProductsChart.jsx'; import { Messages } from '../../Components/Notifications/Messages.jsx'; const commonUrl = import.meta.env.ENV_COMMON_BASE_URL; @@ -97,7 +108,6 @@ const RetailDashboard = () => { const navigate = useNavigate(); const dispatch = useDispatch(); const { RangePicker } = DatePicker; - const [selectedTab, setSelectedTab] = useState('dashboard'); const tabs = [ { value: 'dashboard', label: 'Dashboard' }, { value: 'top-selling-products', label: 'Top Selling Products' }, @@ -116,16 +126,7 @@ const RetailDashboard = () => { ]); const [ismounted, setIsmounted] = useState(true); const [customerPendingBalance, setcustomerPendingBalance] = useState([]); - console.log(PricingAppPricingName, 'PricingAppPricingName'); - // const { - // AppId: appId, - // CompId: compId, - // BranchId: branchId, - // } = SessionData || {}; - // console.log(appId, compId, branchId, 'SessionData'); - const [range1, setRange1] = useState('today'); - const [range2, setRange2] = useState('today'); - const [range3, setRange3] = useState('today'); + const [userprofile, setUserprofile] = useState(false); const userProfileRef = useRef(null); @@ -142,7 +143,6 @@ const RetailDashboard = () => { const [totalPages, setTotalPages] = useState(0); const [loading, setLoading] = useState(false); const [products, setProducts] = useState([]); - console.log(selection, 'selection'); const [CompBranchData, setCompBranchData] = useState(); const [EmpAcces, setEmpAccess] = useState(); const [seletedBranchData, setseletedBranchData] = useState(BranchId); @@ -151,7 +151,6 @@ const RetailDashboard = () => { BrLength == 1 ? null : 'all' ); const [ApiData, setApiData] = useState([]); - console.log(CompBranchData, 'CompBranchData'); const [Zero, SetZero] = useState(false); const [ResponseData, setResponseData] = useState(); const [DateApiData, setDateApiData] = useState([]); @@ -216,18 +215,7 @@ const RetailDashboard = () => { type?.PreferredStatus === 'Y' ); const timerDuration = 30; - let EndDate = AppDetails?.[0]?.ValidityEnd; - const isoDate = EndDate; // <-- July 24 - const date = new Date(isoDate); - - const options = { year: 'numeric', month: 'long', day: 'numeric' }; - const formatted = date.toLocaleDateString('en-US', options); - - // "July 24, 2025" - - console.log(expiredList, lowStockList, 'lowStockList'); - console.log(TopSellingCus, preorderData, 'preorderData'); let DineInData = ApiData?.[0]?.ChartDtl?.map((item) => { return { @@ -441,10 +429,6 @@ const RetailDashboard = () => { if (res?.data?.statusCode === 1 && res?.data?.data?.length > 0) { const remaining = res?.data?.data?.[0]; - // let RemainingDays = expData?.RemainingDays; - // let RemainingHours=expData?.RemainingHours; - // let RemainingMinutes=expData?.RemainingMinutes; - // let RemainingSeconds=expData?.RemainingSeconds const now = new Date(); @@ -1075,39 +1059,6 @@ const RetailDashboard = () => { getSalesHdrFn(); }; - // Function to aggregate data from multiple branches - const aggregateBranchData = (branchDataArray) => { - const aggregated = { - DineInOrderCount: 0, - TakeAwayOrderCount: 0, - SelfTakeAwayOrderCount: 0, - OverAllSalesAmt: 0, - OverAllDineInAmount: 0, - OverAllTakeAwayAmount: 0, - ChartDtl: [], - }; - - branchDataArray.forEach((branchData) => { - if (branchData) { - aggregated.DineInOrderCount += branchData.DineInOrderCount || 0; - aggregated.TakeAwayOrderCount += branchData.TakeAwayOrderCount || 0; - aggregated.SelfTakeAwayOrderCount += - branchData.SelfTakeAwayOrderCount || 0; - aggregated.OverAllSalesAmt += branchData.OverAllSalesAmt || 0; - aggregated.OverAllDineInAmount += branchData.OverAllDineInAmount || 0; - aggregated.OverAllTakeAwayAmount += - branchData.OverAllTakeAwayAmount || 0; - - // Merge chart data (you might want to customize this based on your needs) - if (branchData.ChartDtl && branchData.ChartDtl.length > 0) { - aggregated.ChartDtl = aggregated.ChartDtl.concat(branchData.ChartDtl); - } - } - }); - - return aggregated; - }; - // Helper functions for fetching data from all branches const getpreOrderDashBoardFnAllBranches = async (FromDate, ToDate) => { if (!CompBranchData || CompBranchData.length === 0) return; @@ -1284,14 +1235,6 @@ const RetailDashboard = () => { setApiData([]); } - // const allBranchData = await Promise.all(allBranchPromises); - - // // Aggregate the data from all branches - // const aggregatedData = aggregateBranchData(allBranchData); - // setDateApiData([aggregatedData]); - // setApiData([aggregatedData]); - // setPiedat([aggregatedData]); - // Also refresh other data for all branches with date range getpreOrderDashBoardFnAllBranches(fromDate, toDate); getTopBuyingCustomersAllBranches(fromDate, toDate); @@ -1477,6 +1420,7 @@ const RetailDashboard = () => { ?.toUpperCase()}
{userprofile && ( + { }} Logout={Logout} /> + )} @@ -1511,6 +1456,7 @@ const RetailDashboard = () => { {/* Branch Filter Dropdown */} {CompBranchData?.length > 1 && selection !== 'top-selling-products' && (
+ Loading...
}> { defaultValue="all" placeholder="All Branches" /> + )} @@ -1537,14 +1484,6 @@ const RetailDashboard = () => { className="datepickerDashboardrange" inputReadOnly={true} /> - {/*
-
- {' '} - - Refresh -
- 10sec auto refresh -
*/} {selection === 'dashboard' ? ( @@ -1553,7 +1492,9 @@ const RetailDashboard = () => {
- + }> + +
@@ -2418,28 +2359,6 @@ const RetailDashboard = () => { No Low Stock Product )} - - {/*
-
2
-
-
- Cotton Blend Mandarin Collar Self One Design Kurta -
-
-
4
-
-
-
3
-
-
- Cotton Blend Mandarin Collar Self One Design Kurta -
-
-
1
-
*/} - {/*
- View All -
*/} @@ -2448,106 +2367,110 @@ const RetailDashboard = () => { ) : ( <> - + }> + + )} - + -
- ({ - value: option?.UserId, - label: option?.UserName, - }))} - label={} - className="field-DropDown" - onChangeFunction={(e) => UserDropDownChange(e)} - isOnchanges={selectedUserData ? true : false} - valueData={selectedUserData} - disabled={disabled} - /> -
-
- ChangeMethod(e)} - /> -
-
- - {pinInput && ( -
- {[0, 1, 2, 3].map((i) => ( - (inputRefs.current[i] = el)} - className="inputNumber" - type="text" - inputMode="numeric" - pattern="[0-9]" - maxLength={1} - onChange={(e) => handleChange(i, e)} - onKeyDown={(e) => handleKeyDown(i, e)} - style={{ - textAlign: 'center', - width: '40px', - fontSize: '20px', - }} - /> - ))} -
- )} - -
- + > + <> +
+ ({ + value: option?.UserId, + label: option?.UserName, + }))} + label={} + className="field-DropDown" + onChangeFunction={(e) => UserDropDownChange(e)} + isOnchanges={selectedUserData ? true : false} + valueData={selectedUserData} + disabled={disabled} + /> +
+
+ Loading...
}> + ChangeMethod(e)} + /> +
- - } - /> + + {pinInput && ( +
+ {[0, 1, 2, 3].map((i) => ( + (inputRefs.current[i] = el)} + className="inputNumber" + type="text" + inputMode="numeric" + pattern="[0-9]" + maxLength={1} + onChange={(e) => handleChange(i, e)} + onKeyDown={(e) => handleKeyDown(i, e)} + style={{ + textAlign: 'center', + width: '40px', + fontSize: '20px', + }} + /> + ))} +
+ )} + +
+ +
+
+ + +
); }; diff --git a/src/Pages/DashBoard/TopSellingProductsChart.jsx b/src/Pages/DashBoard/TopSellingProductsChart.jsx index 28d81d9..cb8ca69 100644 --- a/src/Pages/DashBoard/TopSellingProductsChart.jsx +++ b/src/Pages/DashBoard/TopSellingProductsChart.jsx @@ -1,525 +1,561 @@ -import { useState, useEffect, useRef, useLayoutEffect, useMemo } from 'react'; -import { BarChart, Bar, PieChart, Pie, Cell, XAxis, YAxis, CartesianGrid, Legend, Tooltip, ResponsiveContainer } from 'recharts'; -import { TrendingUp, Package, IndianRupee, ChevronLeft, ChevronRight } from 'lucide-react'; +import { + useState, + useEffect, + useRef, + useLayoutEffect, + useMemo, + lazy, + Suspense, +} from 'react'; +import { PieChart, Pie, Cell, Tooltip, ResponsiveContainer } from 'recharts'; +import { TrendingUp, Package, IndianRupee } from 'lucide-react'; import './TopSellingProductsChart.scss'; import { useDispatch } from 'react-redux'; -import { getTopSellingProduct } from '../../Features/ProductPage/ProductPage'; import { getSession } from '../../Services/Others'; import { changeBreadCrumb } from '../../Features/AppPage/CenterPage'; -import { Switch, DatePicker } from 'antd'; -import moment from 'moment'; -import dayjs from 'dayjs'; -import { DropDowns } from '../../Components/Forms/DropDown'; -const { RangePicker } = DatePicker; +import dayjs from 'dayjs'; + +const DropDowns = lazy(() => + import('../../Components/Forms/DropDown').then((module) => ({ + default: module.DropDowns, + })) +); const subDirectory = import.meta.env.BASE_URL; const items = [ - { - name: 'Home', - link: `${subDirectory}app-page/home`, - }, + { + name: 'Home', + link: `${subDirectory}app-page/home`, + }, ]; -const TopSellingProducts = ({ dates = [null, null], products = [], loading = false, totalPages, page = 1, setPage = () => { }, fetchProducts = () => { }, initialDate = true }) => { +const TopSellingProducts = ({ + dates = [null, null], + products = [], + loading = false, + totalPages, + page = 1, + setPage = () => {}, + fetchProducts = () => {}, + initialDate = true, +}) => { + const today = new Date(); + const year = today.getFullYear(); + const month = today.getMonth(); - const today = new Date(); - const year = today.getFullYear(); - const month = today.getMonth(); + const formatDate = (date) => + `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`; - const formatDate = (date) => - `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`; + const intialFromDate = `${year}-${String(month + 1).padStart(2, '0')}-01`; + const intialToDate = formatDate(today); - const intialFromDate = `${year}-${String(month + 1).padStart(2, '0')}-01`; - const intialToDate = formatDate(today); + const dispatch = useDispatch(); - const dispatch = useDispatch(); + const AppId = getSession('AppId'); + const CompId = getSession('CompId'); + const BranchId = getSession('BranchId'); - const AppId = getSession('AppId'); - const CompId = getSession('CompId'); - const BranchId = getSession('BranchId'); + const [chartType, setChartType] = useState('bar'); + const [metric, setMetric] = useState('sales'); + const chartWrapperRef = useRef(null); + const [containerWidth, setContainerWidth] = useState(800); // fallback + const [windowWidth, setWindowWidth] = useState(window.innerWidth); + const [hoveredItem, setHoveredItem] = useState(null); + const [mousePosition, setMousePosition] = useState({ x: 0, y: 0 }); - const [chartType, setChartType] = useState('bar'); - const [metric, setMetric] = useState('sales'); - const chartWrapperRef = useRef(null); - const [containerWidth, setContainerWidth] = useState(800); // fallback - const [windowWidth, setWindowWidth] = useState(window.innerWidth); - const [hoveredItem, setHoveredItem] = useState(null); - const [mousePosition, setMousePosition] = useState({ x: 0, y: 0 }); - const startIndex = (page - 1) * 10; + console.log(products?.[0]?.TotalCount, 'products'); - console.log(products?.[0]?.TotalCount, "products") + const options = useMemo(() => { + const total = products?.[0]?.TotalCount || 0; + const perPage = 10; - const options = useMemo(() => { - const total = products?.[0]?.TotalCount || 0; - const perPage = 10; + const totalPages = Math.ceil(total / perPage); - const totalPages = Math.ceil(total / perPage); + const arr = []; - const arr = []; + for (let page = 1; page <= totalPages; page++) { + const start = (page - 1) * perPage + 1; + const end = Math.min(page * perPage, total); - for (let page = 1; page <= totalPages; page++) { - const start = (page - 1) * perPage + 1; - const end = Math.min(page * perPage, total); - - arr.push({ - label: `${start}-${end}`, - value: page - }); - } - - return arr; - }, [products?.[0]?.TotalCount]); - - useLayoutEffect(() => { - if (!chartWrapperRef.current) return; - const el = chartWrapperRef.current; - - // set initial width - setContainerWidth(el.clientWidth || 800); - - // ResizeObserver to update container width precisely - const ro = new ResizeObserver(entries => { - for (const entry of entries) { - const w = Math.floor(entry.contentRect.width); - if (w && w !== containerWidth) setContainerWidth(w); - } - }); - ro.observe(el); - - return () => ro.disconnect(); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [chartWrapperRef.current]); - // breakpoints - const mobileBreakpoint = 430; // you said < 430px is problematic - const isNarrow = containerWidth <= mobileBreakpoint; - - // compute sizes based on actual container width - // make pie fill a good portion of container (leave some padding) - const pieOuterRadius = Math.max(48, Math.floor(containerWidth * (isNarrow ? 0.36 : 0.28))); - const pieInnerRadius = Math.floor(pieOuterRadius * (isNarrow ? 0.5 : 0.55)); - - // height for ResponsiveContainer: tether to containerWidth so chart stays proportional - const responsiveHeight = Math.max(220, Math.floor(containerWidth * (isNarrow ? 0.62 : 0.5))); - - // tweak minAngle: small screens should allow smaller minAngle so slices remain visible - const minAngle = isNarrow ? 4 : 8; - - - console.log(pieOuterRadius, "pieOuterRadius") - - // const COLORS = ['#2563eb', '#7c3aed', '#db2777', '#ea580c', '#16a34a', '#0891b2', '#d97706', '#65a30d', '#4f46e5', '#0d9488']; - const COLORS = [ - '#4f8df5', // lighter blue (was #2563eb) - '#9a6df3', // lighter violet (was #7c3aed) - '#e95b96', // lighter pink (was #db2777) - '#f48b3c', // lighter orange (was #ea580c) - '#34c86a', // lighter green (was #16a34a) - '#33bcd4', // lighter cyan (was #0891b2) - '#e39a1a', // lighter amber (was #d97706) - '#8bc329', // lighter lime (was #65a30d) - '#6d63ef', // lighter indigo (was #4f46e5) - '#35bfa9' // lighter teal (was #0d9488) - ]; - - useEffect(() => { - try { - dispatch(changeBreadCrumb({ items: items })); - } catch (error) { - console.log(error?.message, 'error displaying breadcrumbs'); - } - }, []); - - const handlePageChange = (data) => { - setPage(prev => prev + data) + arr.push({ + label: `${start}-${end}`, + value: page, + }); } - const CustomTooltip = ({ active, payload }) => { - if (active && payload && payload?.[0]) { - const product = payload?.[0]?.payload; - return ( -
-

{product?.ProdName} - {product?.UOMName}

- {(product?.BrandName) ?

Brand: {product?.BrandName}

: null} -
-

Variants:

- {product?.variantDetails?.map((variant, idx) => ( -
- {variant?.ProdVariantName}: - - {variant?.SalesCount} sold | ₹{variant?.Revenue} - -
- ))} -
-
-
- Total Sales: - {product?.TotalSoldQty} -
-
- Total Revenue: - ₹{product?.TotalRevenue} -
-
-
- ); - } - return null; - }; + return arr; + }, [products?.[0]?.TotalCount]); - const renderPercentInside = ({ - cx, cy, midAngle, innerRadius, outerRadius, percent, value - }) => { - const percentValue = Math.round(percent * 100); - // hide labels for very small percentages on narrow screens - if (percentValue < (isNarrow ? 3 : 2)) return null; + useLayoutEffect(() => { + if (!chartWrapperRef.current) return; + const el = chartWrapperRef.current; - const RADIAN = Math.PI / 180; - // place label inside slice (closer to inner radius on narrow screens) - const radius = innerRadius + (outerRadius - innerRadius) * (isNarrow ? 0.55 : 0.6); + // set initial width + setContainerWidth(el.clientWidth || 800); - const x = cx + radius * Math.cos(-midAngle * RADIAN); - const y = cy + radius * Math.sin(-midAngle * RADIAN); + // ResizeObserver to update container width precisely + const ro = new ResizeObserver((entries) => { + for (const entry of entries) { + const w = Math.floor(entry.contentRect.width); + if (w && w !== containerWidth) setContainerWidth(w); + } + }); + ro.observe(el); - const fontSize = isNarrow ? 10 : 12; + return () => ro.disconnect(); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [chartWrapperRef.current]); + // breakpoints + const mobileBreakpoint = 430; // you said < 430px is problematic + const isNarrow = containerWidth <= mobileBreakpoint; - // choose contrasting color: white usually works on colored slices - return ( - - {/* {`${percentValue}%`} */} - {value} - - ); - }; - const getBenchmarkValue = (maxValue) => { - if (maxValue <= 0) return 100; + // compute sizes based on actual container width + // make pie fill a good portion of container (leave some padding) + const pieOuterRadius = Math.max( + 48, + Math.floor(containerWidth * (isNarrow ? 0.36 : 0.28)) + ); + const pieInnerRadius = Math.floor(pieOuterRadius * (isNarrow ? 0.5 : 0.55)); - const benchmarks = [ - // Fine granularity for small numbers, coarser for large numbers - 1, 2, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, - 60, 70, 80, 90, 100, 125, 150, 175, 200, 225, 250, 275, 300, - 350, 400, 450, 500, 600, 700, 800, 900, 1000, - 1250, 1500, 1750, 2000, 2500, 3000, 3500, 4000, 4500, 5000, - 6000, 7000, 8000, 9000, 10000, 12500, 15000, 17500, 20000, 25000, - 30000, 35000, 40000, 45000, 50000, 60000, 70000, 80000, 90000, 100000, - 125000, 150000, 175000, 200000, 250000, 300000, 350000, 400000, 450000, 500000, - 600000, 700000, 800000, 900000, 1000000 - ]; + // height for ResponsiveContainer: tether to containerWidth so chart stays proportional + const responsiveHeight = Math.max( + 220, + Math.floor(containerWidth * (isNarrow ? 0.62 : 0.5)) + ); - const benchmark = benchmarks.find(b => b >= maxValue); - return benchmark || Math.ceil(maxValue / 10000) * 10000; - }; + // tweak minAngle: small screens should allow smaller minAngle so slices remain visible + const minAngle = isNarrow ? 4 : 8; - const chartData = products?.map(p => ({ - ...p, - name: p?.ProdName, - value: metric === 'sales' ? p?.TotalSoldQty : p?.TotalRevenue, - benchMarkValue: metric === 'sales' ? p?.TotalRevenueCount : p?.TotalRevenueAmount - })); + console.log(pieOuterRadius, 'pieOuterRadius'); - const benchmarkValue = getBenchmarkValue(Math.max(...(chartData?.map(d => d?.benchMarkValue) || [0]))); + // const COLORS = ['#2563eb', '#7c3aed', '#db2777', '#ea580c', '#16a34a', '#0891b2', '#d97706', '#65a30d', '#4f46e5', '#0d9488']; + const COLORS = [ + '#4f8df5', // lighter blue (was #2563eb) + '#9a6df3', // lighter violet (was #7c3aed) + '#e95b96', // lighter pink (was #db2777) + '#f48b3c', // lighter orange (was #ea580c) + '#34c86a', // lighter green (was #16a34a) + '#33bcd4', // lighter cyan (was #0891b2) + '#e39a1a', // lighter amber (was #d97706) + '#8bc329', // lighter lime (was #65a30d) + '#6d63ef', // lighter indigo (was #4f46e5) + '#35bfa9', // lighter teal (was #0d9488) + ]; - return ( -
-
- {/* Header */} - {/*
-
Top Selling Products
-
-
Date Range :
- current && current > moment().endOf('day')} - onChange={async (dates) => { - setDates(dates); - const FromDate = dates?.[0]?.format('YYYY-MM-DD') || intialFromDate; - const ToDate = dates?.[1]?.format('YYYY-MM-DD') || intialToDate; - await fetchProducts({ AppId, CompId, BranchId, FromDate, ToDate, pageNumber: 1 }); - setPage(1); - }} - value={dates} - /> -
-
*/} + useEffect(() => { + try { + dispatch(changeBreadCrumb({ items: items })); + } catch (error) { + console.log(error?.message, 'error displaying breadcrumbs'); + } + }, []); - - {/* Stats Cards */} -
-
-
-
-

Total Products

-

{products?.length}

-
- -
-
-
-
-
-

Total Sales

-

- {products?.reduce((sum, p) => sum + (p?.TotalSoldQty || 0), 0)} -

-
- -
-
-
-
-
-

Total Revenue

-

- ₹{products?.reduce((sum, p) => sum + (p?.TotalRevenue || 0), 0)?.toFixed(2)} -

-
- -
-
-
- - {/* Controls */} -
-
-
-
setMetric('sales')} - className={`btn-metric ${metric === 'sales' ? 'active' : ''}`} - > - - Sales Count -
-
setMetric('revenue')} - className={`btn-metric ${metric === 'revenue' ? 'active' : ''}`} - > - - Revenue -
-
-
- {/* setChartType(checked ? 'bar' : 'pie')} - checkedChildren="Bar Chart" - unCheckedChildren="Pie Chart" - className="bar-pie-switch" - value={chartType === 'bar' ? true : false} - /> */} -
setChartType('bar')} - className={`btn-chart-type ${chartType === 'bar' ? 'active' : ''}`} - > - Bar Chart -
-
setChartType('pie')} - className={`btn-chart-type ${chartType === 'pie' ? 'active' : ''}`} - > - Pie Chart -
-
- {/* {(dates?.[0] && dates?.[1]) && ( -
- -
{`${dates[0]?.format('DD/MMM/YYYY') || intialFromDate} - ${dates[1]?.format('DD/MMM/YYYY') || intialToDate}`}
-
- )} */} - - { - setPage(value); - const FromDate = dates?.[0]?.format('YYYY-MM-DD') || intialFromDate; - const ToDate = dates?.[1]?.format('YYYY-MM-DD') || intialToDate; - await fetchProducts({ AppId, CompId, BranchId, FromDate, ToDate, pageNumber: value }); - }} - isOnchanges={page ? true : false} - /> - -
-
- - {((initialDate ? true : (!dates && !dates?.[0] && !dates?.[1])) && intialFromDate && intialToDate) &&
{`${dayjs(intialFromDate)?.format('DD/MMM/YYYY')} - ${dayjs(intialToDate)?.format('DD/MMM/YYYY')}`}
} - -
- - {/* Chart */} -
- - -
- {loading && products?.length === 0 ? ( -
-
-
- ) : chartData?.length === 0 ? ( -
- No data available -
- ) : ( - <> - {chartType === 'bar' ? ( -
-
-
-
- {[ - 0, - Math.round(benchmarkValue * 0.25), - Math.round(benchmarkValue * 0.5), - Math.round(benchmarkValue * 0.75), - benchmarkValue - ].map((num, i) => ( -
-
-
{num}
-
- ))} -
-
-
- {chartData?.length > 0 ? ( - <> - {chartData?.map((item, index) => ( -
{ - setHoveredItem(item); - setMousePosition({ x: e.clientX, y: e.clientY }); - }} - // style={{}} - onMouseLeave={() => setHoveredItem(null)} - onMouseMove={(e) => setMousePosition({ x: e.clientX, y: e.clientY })} - > -
{`#${(index + 1) + ((page - 1) * 10)}`}{item?.name}
-
- -
- - {/* {((item?.value / Math.max(...chartData.map(d => d?.value))) * 100).toFixed(1)}% */} - -
-
-
{item?.value}
-
- ))} - - - ) : ( -
-
-
No Data
-
0
-
-
- )} -
- ) : ( - /* Replace your existing with this */ - /* PIE + RIGHT-LEGEND: replace the existing pie rendering */ -
-
- - - - {chartData.map((entry, index) => ( - - ))} - - } /> - - -
- -
- {(() => { - const total = chartData.reduce((s, d) => s + (Number(d?.value || 0)), 0) || 1; - return chartData.map((d, i) => { - const color = COLORS[i % COLORS.length]; - const value = Number(d?.value || 0); - const percent = total ? ((value / total) * 100) : 0; - return ( -
- -
-
{d?.name}
-
- {value} - {percent.toFixed(2)}% -
-
-
- ); - }); - })()} -
-
- - )} - - - )} -
- -
-
+ const CustomTooltip = ({ active, payload }) => { + if (active && payload && payload?.[0]) { + const product = payload?.[0]?.payload; + return ( +
+

+ {product?.ProdName} - {product?.UOMName} +

+ {product?.BrandName ? ( +

Brand: {product?.BrandName}

+ ) : null} +
+

Variants:

+ {product?.variantDetails?.map((variant, idx) => ( +
+ + {variant?.ProdVariantName}: + + + {variant?.SalesCount} sold | ₹{variant?.Revenue} + +
+ ))} +
+
+
+ Total Sales: + {product?.TotalSoldQty}
- {hoveredItem && ( -
- -
- )} +
+ Total Revenue: + ₹{product?.TotalRevenue} +
+
+ ); + } + return null; + }; + + const renderPercentInside = ({ + cx, + cy, + midAngle, + innerRadius, + outerRadius, + percent, + value, + }) => { + const percentValue = Math.round(percent * 100); + // hide labels for very small percentages on narrow screens + if (percentValue < (isNarrow ? 3 : 2)) return null; + + const RADIAN = Math.PI / 180; + // place label inside slice (closer to inner radius on narrow screens) + const radius = + innerRadius + (outerRadius - innerRadius) * (isNarrow ? 0.55 : 0.6); + + const x = cx + radius * Math.cos(-midAngle * RADIAN); + const y = cy + radius * Math.sin(-midAngle * RADIAN); + + const fontSize = isNarrow ? 10 : 12; + + // choose contrasting color: white usually works on colored slices + return ( + + {/* {`${percentValue}%`} */} + {value} + ); + }; + const getBenchmarkValue = (maxValue) => { + if (maxValue <= 0) return 100; + + const benchmarks = [ + // Fine granularity for small numbers, coarser for large numbers + 1, 2, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 100, 125, + 150, 175, 200, 225, 250, 275, 300, 350, 400, 450, 500, 600, 700, 800, 900, + 1000, 1250, 1500, 1750, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 6000, + 7000, 8000, 9000, 10000, 12500, 15000, 17500, 20000, 25000, 30000, 35000, + 40000, 45000, 50000, 60000, 70000, 80000, 90000, 100000, 125000, 150000, + 175000, 200000, 250000, 300000, 350000, 400000, 450000, 500000, 600000, + 700000, 800000, 900000, 1000000, + ]; + + const benchmark = benchmarks.find((b) => b >= maxValue); + return benchmark || Math.ceil(maxValue / 10000) * 10000; + }; + + const chartData = products?.map((p) => ({ + ...p, + name: p?.ProdName, + value: metric === 'sales' ? p?.TotalSoldQty : p?.TotalRevenue, + benchMarkValue: + metric === 'sales' ? p?.TotalRevenueCount : p?.TotalRevenueAmount, + })); + + const benchmarkValue = getBenchmarkValue( + Math.max(...(chartData?.map((d) => d?.benchMarkValue) || [0])) + ); + + return ( +
+
+ {/* Stats Cards */} +
+
+
+
+

Total Products

+

{products?.length}

+
+ +
+
+
+
+
+

Total Sales

+

+ {products?.reduce( + (sum, p) => sum + (p?.TotalSoldQty || 0), + 0 + )} +

+
+ +
+
+
+
+
+

Total Revenue

+

+ ₹ + {products + ?.reduce((sum, p) => sum + (p?.TotalRevenue || 0), 0) + ?.toFixed(2)} +

+
+ +
+
+
+ + {/* Controls */} +
+
+
+
setMetric('sales')} + className={`btn-metric ${metric === 'sales' ? 'active' : ''}`} + > + + Sales Count +
+
setMetric('revenue')} + className={`btn-metric ${metric === 'revenue' ? 'active' : ''}`} + > + + Revenue +
+
+
+
setChartType('bar')} + className={`btn-chart-type ${chartType === 'bar' ? 'active' : ''}`} + > + Bar Chart +
+
setChartType('pie')} + className={`btn-chart-type ${chartType === 'pie' ? 'active' : ''}`} + > + Pie Chart +
+
+ + Loading...
}> + { + setPage(value); + const FromDate = + dates?.[0]?.format('YYYY-MM-DD') || intialFromDate; + const ToDate = + dates?.[1]?.format('YYYY-MM-DD') || intialToDate; + await fetchProducts({ + AppId, + CompId, + BranchId, + FromDate, + ToDate, + pageNumber: value, + }); + }} + isOnchanges={page ? true : false} + /> + +
+
+ + {(initialDate ? true : !dates && !dates?.[0] && !dates?.[1]) && + intialFromDate && + intialToDate && ( +
{`${dayjs(intialFromDate)?.format('DD/MMM/YYYY')} - ${dayjs(intialToDate)?.format('DD/MMM/YYYY')}`}
+ )} + +
+ {/* Chart */} +
+
+ {loading && products?.length === 0 ? ( +
+
+
+ ) : chartData?.length === 0 ? ( +
No data available
+ ) : ( + <> + {chartType === 'bar' ? ( +
+
+
+
+ {[ + 0, + Math.round(benchmarkValue * 0.25), + Math.round(benchmarkValue * 0.5), + Math.round(benchmarkValue * 0.75), + benchmarkValue, + ].map((num, i) => ( +
+
+
{num}
+
+ ))} +
+
+
+ {chartData?.length > 0 ? ( + <> + {chartData?.map((item, index) => ( +
{ + setHoveredItem(item); + setMousePosition({ + x: e.clientX, + y: e.clientY, + }); + }} + // style={{}} + onMouseLeave={() => setHoveredItem(null)} + onMouseMove={(e) => + setMousePosition({ x: e.clientX, y: e.clientY }) + } + > +
+ {`#${index + 1 + (page - 1) * 10}`} + {item?.name} +
+
+
+ + {/* {((item?.value / Math.max(...chartData.map(d => d?.value))) * 100).toFixed(1)}% */} + +
+
+
+ {item?.value} +
+
+ ))} + + ) : ( +
+
+
No Data
+
0
+
+
+ )} +
+ ) : ( + /* Replace your existing with this */ + /* PIE + RIGHT-LEGEND: replace the existing pie rendering */ +
+
+ + + + {chartData.map((entry, index) => ( + + ))} + + } /> + + +
+ +
+ {(() => { + const total = + chartData.reduce( + (s, d) => s + Number(d?.value || 0), + 0 + ) || 1; + return chartData.map((d, i) => { + const color = COLORS[i % COLORS.length]; + const value = Number(d?.value || 0); + const percent = total ? (value / total) * 100 : 0; + return ( +
+ +
+
{d?.name}
+
+ + {value} + + + {percent.toFixed(2)}% + +
+
+
+ ); + }); + })()} +
+
+ )} + + )} +
+
+
+
+ {hoveredItem && ( +
+ +
+ )} +
+ ); }; -export default TopSellingProducts; \ No newline at end of file +export default TopSellingProducts; diff --git a/src/Pages/Kiosk/KioskBookingPage.jsx b/src/Pages/Kiosk/KioskBookingPage.jsx index b224cc0..8313af3 100644 --- a/src/Pages/Kiosk/KioskBookingPage.jsx +++ b/src/Pages/Kiosk/KioskBookingPage.jsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import { useEffect, useState } from 'react'; import { useSelector, useDispatch } from 'react-redux'; import axios from 'axios'; import { Skeleton } from 'antd'; @@ -64,119 +64,7 @@ const KioskBookingPage = () => { }; useEffect(() => { - // const fetchData = async () => { - // const queryParams = await getQueryParams(); - - // console.log("queryParams", queryParams) - // if (Object.keys(queryParams)?.length !== 0) { - - // console.log("queryParams", queryParams) - // if(!sessionStorage.getItem('auth')){ - // let data = { - // username: "1000000001", - // password: "1234" - // } - // const response = await axios.post(`${apiUrlToken}/jwtTokenGenerator`, data, { - // headers: { - // 'Content-Type': 'application/json', - // 'Accept': 'application/json', - // }, - // }); - - // const { token } = response?.data; - // sessionStorage.setItem('auth', token) - // sessionStore("LoginType","Kiosk") - // } - // const MACAddress = queryParams?.MD - // if (MACAddress) { - // console.log("MACAddress", MACAddress) - // setDeviceAddress(MACAddress) - // setDevicePresent(true) - // let deviceMACResponse = await dispatch(getDeviceAccess({ DeviceAddress: MACAddress })).unwrap(); - // if (deviceMACResponse?.data?.statusCode == 1 && deviceMACResponse?.data?.data?.length > 0 && deviceMACResponse?.data?.data?.[0]?.KioskStatus === 'Y') { - // setDeviceAccess(true) - // let responseData = deviceMACResponse?.data?.data?.[0] - // responseData?.MobileNo != null && responseData?.MobileNo != undefined && sessionStore("MobileNo", responseData?.MobileNo); - // responseData?.UserId != null && responseData?.UserId != undefined && sessionStore("UserId", responseData?.UserId); - // responseData?.UserType != null && responseData?.UserType != undefined && sessionStore("UserType", responseData?.UserType); - // responseData?.CompId != null && responseData?.CompId != undefined && sessionStore("CompId", responseData?.CompId); - // responseData?.CompName != null && responseData?.CompName != undefined && sessionStore("CompName", responseData?.CompName); - // responseData?.AppId != null && responseData?.AppId != undefined && sessionStore("AppId", responseData?.AppId); - // responseData?.AppName != null && responseData?.AppName != undefined && sessionStore("AppName", responseData?.AppName); - // responseData?.BranchId != null && responseData?.BranchId != undefined && sessionStore("BranchId", responseData?.BranchId); - // responseData?.userName != null && responseData?.userName != undefined && sessionStore("userName", responseData?.UserName); - // responseData?.SessionId != null && responseData?.SessionId != undefined && sessionStore("SessionId", responseData?.SessionId); - // sessionStore("hasRefreshed", true); - // dispatch(getKioskTemplate({ CompId: responseData?.CompId, BranchId: responseData?.BranchId, AppId: responseData?.AppId })).unwrap(); - // dispatch(getProductCategories({ CompId: responseData?.CompId, BranchId: responseData?.BranchId, AppId: responseData?.AppId })).unwrap(); - // } else { - // setDeviceAccess(false) - // } - // } else { - // const MobileNoValue = decryptedValuesFun(queryParams?.MN); - // const UserIdValue = decryptedValuesFun(queryParams?.UD); - // const UserTypeValue = decryptedValuesFun(queryParams?.UT); - // const CompIdValue = decryptedValuesFun(queryParams?.CD); - // const AppIdValue = decryptedValuesFun(queryParams?.AD); - // const BranchIdValue = decryptedValuesFun(queryParams?.BD); - // const OrderIdValue = decryptedValuesFun(queryParams?.OD); - // const AmountValue = decryptedValuesFun(queryParams?.AM); - // let CompNameValue = null, AppNameValue = null; - // if (CompIdValue) { - // let response = await dispatch(getCompanyData({ CompId: CompIdValue })).unwrap(); - // if (response?.data?.statusCode == 1) { - // CompNameValue = response?.data?.data?.[0]?.["CompName"]; - // } else { - // CompNameValue = null; - // } - // } - // if (AppIdValue) { - // let appResponse = await dispatch(getAllApplications({ AppId: AppIdValue })).unwrap(); - // if (appResponse?.data?.statusCode == 1) { - // AppNameValue = appResponse?.data?.data?.[0]?.["AppName"]; - // } else { - // AppNameValue = null; - // } - // } - // let userNameValue = null; - // if (queryParams?.UN != null && queryParams?.UN != undefined) { - // userNameValue = decryptedValuesFun(queryParams?.UN); - // } - // console.log("queryParams", MobileNoValue, UserIdValue, UserTypeValue, CompIdValue, AppIdValue, BranchIdValue) - // if (MobileNoValue && UserIdValue && UserTypeValue && CompIdValue && AppIdValue && BranchIdValue) { - // sessionStore("MobileNo", MobileNoValue); - // sessionStore("UserId", UserIdValue); - // sessionStore("UserType", UserTypeValue); - // sessionStore("CompId", CompIdValue); - // sessionStore("CompName", CompNameValue); - // sessionStore("AppId", AppIdValue); - // sessionStore("AppName", AppNameValue); - // sessionStore("BranchId", BranchIdValue); - // if (userNameValue != null) { - // sessionStore("userName", userNameValue); - // } - // dispatch(getKioskTemplate({ CompId: CompIdValue, BranchId: BranchIdValue, AppId: AppIdValue })).unwrap(); - // dispatch(getProductCategories({ CompId: CompIdValue, BranchId: BranchIdValue, AppId: AppIdValue })).unwrap(); - // dispatch(changeKioskPageName('OrderView')) - // dispatch(changePaymentgatewayRedirect(true)) - // dispatch(changeKioskCustomerMobileNo(MobileNoValue)) - // dispatch(changePGFailedTransId(OrderIdValue)) - // dispatch(changePGFailedAmt(AmountValue)) - // const url = new URL(window.location); - // url.search = ''; - // window.history.replaceState({}, document.title, url.toString()); - // } - // else { - // console.error("One or more decrypted values are null."); - // } - // } - - // } else { - // dispatch(getKioskTemplate({ CompId: CompId, BranchId: BranchId, AppId: AppId })).unwrap(); - // dispatch(getProductCategories({ CompId: CompId, BranchId: BranchId, AppId: AppId })).unwrap(); - // } - // } fetchData(); }, []); diff --git a/src/ProtectedRoutes.jsx b/src/ProtectedRoutes.jsx index 665d49c..74b0003 100644 --- a/src/ProtectedRoutes.jsx +++ b/src/ProtectedRoutes.jsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import { useEffect, useState } from 'react'; import { Routes, Route, useNavigate } from 'react-router-dom'; import { useDispatch } from 'react-redux'; import { @@ -29,20 +29,14 @@ const ProtectedRoutes = ({ routesConfig }) => { const UserId = getSession('UserId'); const sessionId = getSession('SessionId'); const [accessCheckComplete, setAccessCheckComplete] = useState(false); - const[AppPreference,setAppPreference]= useState([]); - const kioskPath = `${subDirectory}kiosksales`; // or your actual path - useEffect(()=>{ - getApplicationPreference() - },[]) + useEffect(() => { + getApplicationPreference(); + }, []); - const getApplicationPreference = async()=>{ - - const response = await dispatch(getCommonAppPreference(AppId)).unwrap(); - if (response?.data?.statusCode === 1) { - setAppPreference(response?.data?.data) - } - } + const getApplicationPreference = async () => { + await dispatch(getCommonAppPreference(AppId)).unwrap(); + }; const getEmpAccess = async () => { let data = { @@ -90,7 +84,7 @@ const ProtectedRoutes = ({ routesConfig }) => { ?.SettingDtlDetails?.some( (e) => e.SettingIdName === 'Estimation' && e.SettingValue === 'Y' ); - return SettingValueData, EstimateValueData; + return (SettingValueData, EstimateValueData); } } }; @@ -123,10 +117,10 @@ const ProtectedRoutes = ({ routesConfig }) => { const hasAdvance = pricingData?.some( (item) => item.PricingName === 'Premium' ); - console.log(pricingData,"pricingDatapricingData") const hasProOrAdvance = - hasAdvance || pricingData.some((item) => item.PricingName === 'Customized'); - return hasAdvance, hasProOrAdvance; + hasAdvance || + pricingData.some((item) => item.PricingName === 'Customized'); + return (hasAdvance, hasProOrAdvance); } catch (error) { console.error('Error fetching pricing name:', error); } @@ -320,20 +314,20 @@ const ProtectedRoutes = ({ routesConfig }) => { ]; // Cmd it start - // if (!UserId && empAccessData != 'Public') { - // if (!UserId && (empAccessData === "Kiosk Sales" || empAccessData === "View Bill")) { - // // Allow KioskBookingPage to load and set session values - // setAccessCheckComplete(true); - // return; - // }else{ - // console.log("UserId is undefined, logging out..."); - // // alert("User invalid. Redirecting to login...") - // sessionStorage.clear(); - // window.location.replace(`${commonUrl}`); - // setHasRedirected(true); - // return; - // } - // } + // if (!UserId && empAccessData != 'Public') { + // if (!UserId && (empAccessData === "Kiosk Sales" || empAccessData === "View Bill")) { + // // Allow KioskBookingPage to load and set session values + // setAccessCheckComplete(true); + // return; + // }else{ + // console.log("UserId is undefined, logging out..."); + // // alert("User invalid. Redirecting to login...") + // sessionStorage.clear(); + // window.location.replace(`${commonUrl}`); + // setHasRedirected(true); + // return; + // } + // } // Cmd it End const userAccessChecks = { diff --git a/src/main.jsx b/src/main.jsx index cc6973b..46df9ad 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import ReactDOM from 'react-dom/client'; import { Provider } from 'react-redux'; import { BrowserRouter } from 'react-router-dom'; @@ -7,24 +6,21 @@ import './Fonts/Gilroy/stylesheet.css'; import './index.css'; import AppRoutes from './App.jsx'; import { AuthProvider } from './AuthContext'; -import GlobalErrorHandler from './GlobalErrorHandler'; -import {QueryClient, QueryClientProvider,} from '@tanstack/react-query'; -import {ReactQueryDevtools } from '@tanstack/react-query-devtools'; +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; +import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; const queryClient = new QueryClient(); ReactDOM.createRoot(document.getElementById('root')).render( - - - - - - - - - -{process.env.NODE_ENV == "development" && ( - -)} + + + + + + + + {process.env.NODE_ENV == 'development' && ( + + )} ); diff --git a/src/routesConfig.jsx b/src/routesConfig.jsx index d9b5148..468c7ba 100644 --- a/src/routesConfig.jsx +++ b/src/routesConfig.jsx @@ -1,209 +1,673 @@ import React from 'react'; -import AppPage from './Pages/AppPage/AppPage.jsx'; -import WholesaleAppPage from './Pages/AppPage/WholesaleAppPage.jsx'; -import Home from './Pages/DashBoard/RetailDashboard.jsx'; -import CommonMaster from './Pages/CommonMaster/CommonMaster.jsx'; -import ConfigType from './Pages/ConfigType/ConfigTypeForm.jsx'; -import AdminTax from './Pages/AdminTax/AdminTaxForm.jsx'; -import ProductForm from './Pages/Product/ProductForm.jsx'; -import Sport_ProductForm from './Pages/Product/SportsMaster.jsx'; -import ProductList from './Pages/Product/ProductList.jsx'; -import ShiftMasterList from './Pages/ShiftMaster/ShiftMasterList.jsx'; -import ShiftMasterForm from './Pages/ShiftMaster/ShiftMasterForm.jsx'; -import EmployeeMasterList from './Pages/EmpMaster/EmpMasterList.jsx'; -import EmployeeMasterForm from './Pages/EmpMaster/EmpMasterForm.jsx'; -import SupplierMasterList from './Pages/SupplierMaster/SupplierMasterList.jsx'; -import SupplierMasterForm from './Pages/SupplierMaster/SupplierMasterForm.jsx'; -import ComponentMasterForm from './Pages/UiComponentPage/ComponentForm.jsx'; -import ComponentMasterList from './Pages/UiComponentPage/ComponentList.jsx'; -import CustomerForm from './Pages/CustomerMaster/CustMasterForm.jsx'; -import CustomerMasterList from './Pages/CustomerMaster/CustMasterList.jsx'; -import DateWiseReport from './Pages/Reports/DateWiseReport/DateWiseReport.jsx'; -import ItemWiseReport from './Pages/Reports/ItemWiseReport/ItemWiseReport.jsx'; -import Reprint from './Pages/BookingScreen/Components/OtherConponents/Reprint/BSReprint.jsx'; -import BookingSelectionPage from './Pages/BookingScreen/Components/MainPage/MainPage.jsx'; -import PrintSelectionPage from './Pages/BookingScreen/Components/PrintMainPage/MainPage.jsx'; -import KioskMainPage from './Pages/BookingScreen/Components/Kiosk/KioskMainPage.jsx'; -import BookingPage from './Pages/BookingScreen/BookingPage.jsx'; -import StockForm from './Pages/StockMaster/StockForm.jsx'; -import StockList from './Pages/StockMaster/StockList.jsx'; -import DiningMasterList from './Pages/Dining/DiningList.jsx'; -import DiningMasterForm from './Pages/Dining/DiningForm.jsx'; -import TableBooking from './Pages/Tablebooking/TableBooking.jsx'; -import ComboMaster from './Pages/ComboPack/ComboMaster.jsx'; -import ComboList from './Pages/ComboPack/ComboMasterlist.jsx'; -import EmpAccessForm from './Pages/EmpAccess/EmpAccessForm.jsx'; -import EmpAccessList from './Pages/EmpAccess/EmpAccessList.jsx'; -import EmpScreenAccessList from './Pages/EmpScreenAccess/EmpScreenAccessList.jsx'; -import EmpScreenRightsAccess from './Pages/EmpScreenAccess/EmpScreenRightsAccess.jsx'; -import PreferenceList from './Pages/Preference/PreferenceList.jsx'; -import PaymentOptions from './Pages/Payment/PaymentOptions/PaymentOptions.jsx'; -import PaymentDetails from './Pages/Payment/PaymentDetails/PaymentDetailsForm.jsx'; -import PaymentDetailsList from './Pages/Payment/PaymentDetails/PaymentDetailsList.jsx'; -import PaymentReceivedRetail from './Pages/Payment/PaymentReceivedRetail/PaymentReceivedRetail.jsx'; -import ExtraChargesList from './Pages/ExtraCharges/ExtraChargesList.jsx'; -import BranchLogin from './Pages/BranchLogin/BranchLogin.jsx'; -import BackToBranchLogin from './Pages/BranchLogin/BackToBranchLogin.jsx'; -import Logout from './Pages/Logout.jsx'; -import BacktoLogin from './Pages/BranchLogin/BacktoLogin.jsx'; -import StockPriceUpdate from './Pages/StockPriceUpdate/StockPriceUpdate.jsx'; -import ProductCatalogueList from './Pages/ProductCatlogue/ProductcatlogueList.jsx'; -import KOT from './Pages/Reports/KOT/kot.jsx'; -import CustomerKOTDisplay from './Pages/Reports/KOT/CustomerKOTDisplay.jsx'; -import RedirectApps from './Pages/RedirectApps.jsx'; -import WSTransaction from './Pages/WholeSaleTransaction/WSSalesTransaction.jsx'; -import LedgerReport from './Pages/Reports/LedgerReport/LedgerReport.jsx'; -import PaymentDetailsPage from './Pages/BookingScreen/Components/BookingFunctionality/PaymentDetailsPage.jsx'; -import CreditCustomerPrint from './Pages/BookingScreen/Components/BookingFunctionality/CreditDownloadpage.jsx'; -import Cancellation from './Pages/CancelReschedule/Cancellation.jsx'; -import ChangePaymentmode from './Pages/CancelReschedule/ChangePaymentmode.jsx'; -import CancellationList from './Pages/CancelReschedule/CancellationList.jsx'; -import CancelApplicableProd from './Pages/CancelReschedule/CancelApplicableProd.jsx'; -import CancellationListPending from './Pages/CancelReschedule/CancelPendingPayment.jsx'; -import AndroidApp from './Pages/AndroidApp/AndroidApp.jsx'; -import EstimateItemWiseReport from './Pages/Reports/Estimate/EstimateItemWiseReport.jsx'; -import EstimateDateWiseReport from './Pages/Reports/Estimate/EstimateDateWiseReport.jsx'; -import OfferForm from './Pages/Offer/Offer/OfferFormNew.jsx'; -import OfferList from './Pages/Offer/Offer/OfferListNew.jsx'; -import ItemWise from './Pages/Offer/ItemOffer/ItemWiseForm.jsx'; -import SalesWiseForm from './Pages/Offer/SalesOffer/SalesWiseForm.jsx'; -import SalesWiseList from './Pages/Offer/SalesOffer/SalesWiseList.jsx'; -import QuantityWise from './Pages/Offer/QuantityOffer/QuantityWiseForm.jsx'; -import BuyOneGetOneForm from './Pages/Offer/BuyOneGetOneOffer/BuyOneGetOneForm.jsx'; -// import LoyaltyPointsForm from "./Pages/Offer/LoyaltyPoints/LoyaltyPointsForm.jsx"; -import LoyaltyPointsList from './Pages/Offer/LoyaltyPoints/LoyaltyPointsList.jsx'; -import BundleOfferForm from './Pages/Offer/BundleOffer/BundleOfferForm.jsx'; -import BundleOfferList from './Pages/Offer/BundleOffer/BundleOfferList.jsx'; -// import CouponWiseOffer from "./Pages/Offer/CouponOffer/CouponWiseOfferForm.jsx" -import CouponWiseOfferlist from './Pages/Offer/CouponOffer/CouponWiseOfferlist.jsx'; -import PromocodeList from './Pages/Offer/PromoCode/PromocodeList.jsx'; -// import PromocodeForm from "./Pages/Offer/PromoCode/PromocodeForm.jsx"; -import OfferCodeList from './Pages/Offer/OfferCode/OfferCodeList.jsx'; -// import OfferCodeForm from "./Pages/Offer/OfferCode/OfferCodeForm.jsx"; -import PricingPage from './Pages/BookingScreen/Components/UtillComponents/PricingPage.jsx'; -import PurchaseOrder from './Pages/PurchaseOrder/PurchaseOrder.jsx'; -import PurchaseOrderMail from './Pages/PurchaseOrder/PurchaseOrderMail.jsx'; -import PurchaseOrderList from './Pages/PurchaseOrder/PurchaseOrderList.jsx'; -import StockReceivedList from './Pages/StockTransfer/StockReceivedList.jsx'; -import GstInvoiceSetUpForm from './Pages/GstInvoiceSetup/GstInvoiceSetUpForm.jsx'; -import gstInvoiceSetUpList from './Pages/GstInvoiceSetup/GstInvoiceSetupList.jsx'; -import StockinHand from './Pages/StockinHand/StockinHand.jsx'; +import { lazy } from 'react'; +const CommonMaster = lazy( + () => import('./Pages/CommonMaster/CommonMaster.jsx') +); +const ConfigType = lazy(() => import('./Pages/ConfigType/ConfigTypeForm.jsx')); +const AdminTax = lazy(() => import('./Pages/AdminTax/AdminTaxForm.jsx')); +const ProductForm = lazy(() => import('./Pages/Product/ProductForm.jsx')); +const Sport_ProductForm = lazy( + () => import('./Pages/Product/SportsMaster.jsx') +); +const ShiftMasterList = lazy( + () => import('./Pages/ShiftMaster/ShiftMasterList.jsx') +); +const ShiftMasterForm = lazy( + () => import('./Pages/ShiftMaster/ShiftMasterForm.jsx') +); +const EmployeeMasterList = lazy( + () => import('./Pages/EmpMaster/EmpMasterList.jsx') +); +const EmployeeMasterForm = lazy( + () => import('./Pages/EmpMaster/EmpMasterForm.jsx') +); -import PurchaseReturn from './Pages/PurchaseReturn/purchaseReturn.jsx'; -import PurchaseReturnget from './Pages/PurchaseReturn/PurchaseReturnGet.jsx'; -import KioskBookingPage from './Pages/Kiosk/KioskBookingPage.jsx'; -import KioskBookingReceipt from './Pages/Kiosk/PaymentGateway/PaymentGatewayReceipt.jsx'; -import KioskComponentList from './Pages/KioskComponent/KioskComponentList.jsx'; -import CustomerDisplay from './Pages/CustomerDisplay/CustomerDisplay.jsx'; -import PurchaseQuotationForm from './Pages/PurchaseQuotation/PurchaseQuotationForm.jsx'; -import DeliveryChallanForm from './Pages/DeliveryChallan/Deliverychallan.jsx'; -import DeliveryChallanList from './Pages/DeliveryChallan/DeliverychallanList.jsx'; -import ComboOfferMaster from './Pages/Offer/ComboOfferPack/ComboOfferForm.jsx'; -import PaymentDeviceForm from './Pages/Payment/PaymentDevice/PaymentDeviceForm.jsx'; -import PaymentFailedDetailsList from './Pages/Payment/PaymentFailedDetails/PaymentFailedDetailsList.jsx'; -import CounterCategoryMappingForm from './Pages/CounterCategoryMapping/CounterCategoryMappingForm.jsx'; -import ImageBulkUpload from './Pages/ImageBulkUpload/ImageBulkUpload.jsx'; -import WholesaleBookingPage from './Pages/PurchaseScreen/LayoutScreen8/LayoutScreen8.jsx'; -import WholeSaleProductList from './Pages/Wholesale/ProductList.jsx'; -import ProductEntry from './Pages/Wholesale/ProductEntry.jsx'; -import ProductEntryList from './Pages/Wholesale/ProductEntryList.jsx'; -import ItemEntry from './Pages/Wholesale/ItemEntry/ItemEntry.jsx'; -import WsPreorder from './Pages/Wholesalespreorder/WholesalePreorderList.jsx'; -import WsPreorderForm from './Pages/Wholesalespreorder/WholesalePreorderForm.jsx'; -import ExtraChrgesList from './Pages/Wholesale/ItemEntry/ExtraChrgesList.jsx'; -import SalesBillCancel from './Pages/SalesRemoval/SalesBillCancelList.jsx'; -import WholeSaleAbstract from './Pages/WholeSaleAbstract/WholeSaleAbstract.jsx'; -import WholeSaleSellerAbstract from './Pages/WholeSaleAbstract/WholeSaleSellerAbstract.jsx'; -import PaymentReceived from './Pages/WholeSaleTransaction/PaymentReceived.jsx'; -import WholeSaleSalesReport from './Pages/WholeSaleReport/WholeSalesSalesReport.jsx'; -import WholeSalePurchaseReport from './Pages/WholeSaleReport/WholeSalePurchaseReport.jsx'; -import WholeSalePaymentPurchaseReport from './Pages/WholesalePaymentReport/WholeSalePaymentPurchaseReport.jsx'; -import WholeSalePaymentSalesReport from './Pages/WholesalePaymentReport/WholeSalePaymementSaleReport.jsx'; -import SpeechLanguagesList from './Pages/SpeechLanguages/SpeechLanguagesList.jsx'; -import LegderList from './Pages/WholeSaleLedger/WholeSaleLedger.jsx'; -import SellerMasterTran from './Pages/WholeSaleTransaction/SellerMasterTransaction.jsx'; -import TicketForm from './Pages/Ticket/TicketForm.jsx'; -import ThemeCreation from './Pages/BookingScreen/Components/ThemeCreation/ThemeList.jsx'; -import ThemeSelection from './Pages/BookingScreen/Components/ThemeCreation/ThemePreview.jsx'; -import BarcodeTemplateSetup from './Pages/BarcodeSetup/BarcodeTemplateSetup.jsx'; -import BarcodeComponentList from './Pages/BarcodeComponent/BarcodeComponentList.jsx'; -import StoreRecipelist from './Pages/StoreKitchen/StoreRecipe/StoreRecipelist.jsx'; -import StoreRecipeform from './Pages/StoreKitchen/StoreRecipe/StoreRecipeform.jsx'; -import Storekitchenlist from './Pages/StoreKitchen/StoretoKitchen/StoretoKitchenlist.jsx'; -import StoreKitchenform from './Pages/StoreKitchen/StoretoKitchen/Storetokitchenform.jsx'; -import { axiosCommonInstanceData } from './Features/AuthenicationToken/AuthenticationToken'; +const SupplierMasterList = lazy( + () => import('./Pages/SupplierMaster/SupplierMasterList.jsx') +); +const SupplierMasterForm = lazy( + () => import('./Pages/SupplierMaster/SupplierMasterForm.jsx') +); + +const ComponentMasterForm = lazy( + () => import('./Pages/UiComponentPage/ComponentForm.jsx') +); +const ComponentMasterList = lazy( + () => import('./Pages/UiComponentPage/ComponentList.jsx') +); + +const CustomerForm = lazy( + () => import('./Pages/CustomerMaster/CustMasterForm.jsx') +); +const CustomerMasterList = lazy( + () => import('./Pages/CustomerMaster/CustMasterList.jsx') +); + +const DateWiseReport = lazy( + () => import('./Pages/Reports/DateWiseReport/DateWiseReport.jsx') +); + +const ItemWiseReport = lazy( + () => import('./Pages/Reports/ItemWiseReport/ItemWiseReport.jsx') +); + +const Reprint = lazy( + () => + import('./Pages/BookingScreen/Components/OtherConponents/Reprint/BSReprint.jsx') +); + +const BookingSelectionPage = lazy( + () => import('./Pages/BookingScreen/Components/MainPage/MainPage.jsx') +); + +const PrintSelectionPage = lazy( + () => import('./Pages/BookingScreen/Components/PrintMainPage/MainPage.jsx') +); +const KioskMainPage = lazy( + () => import('./Pages/BookingScreen/Components/Kiosk/KioskMainPage.jsx') +); + +const BookingPage = lazy(() => import('./Pages/BookingScreen/BookingPage.jsx')); + +const StockForm = lazy(() => import('./Pages/StockMaster/StockForm.jsx')); + +const StockList = lazy(() => import('./Pages/StockMaster/StockList.jsx')); + +const DiningMasterList = lazy(() => import('./Pages/Dining/DiningList.jsx')); + +const DiningMasterForm = lazy(() => import('./Pages/Dining/DiningForm.jsx')); + +const TableBooking = lazy( + () => import('./Pages/Tablebooking/TableBooking.jsx') +); + +const ComboMaster = lazy(() => import('./Pages/ComboPack/ComboMaster.jsx')); + +const ComboList = lazy(() => import('./Pages/ComboPack/ComboMasterlist.jsx')); +const EmpAccessForm = lazy(() => import('./Pages/EmpAccess/EmpAccessForm.jsx')); +const EmpAccessList = lazy(() => import('./Pages/EmpAccess/EmpAccessList.jsx')); + +const EmpScreenAccessList = lazy( + () => import('./Pages/EmpScreenAccess/EmpScreenAccessList.jsx') +); +const EmpScreenRightsAccess = lazy( + () => import('./Pages/EmpScreenAccess/EmpScreenRightsAccess.jsx') +); + +const PreferenceList = lazy( + () => import('./Pages/Preference/PreferenceList.jsx') +); + +const PaymentOptions = lazy( + () => import('./Pages/Payment/PaymentOptions/PaymentOptions.jsx') +); +const PaymentDetails = lazy( + () => import('./Pages/Payment/PaymentDetails/PaymentDetailsForm.jsx') +); +const PaymentDetailsList = lazy( + () => import('./Pages/Payment/PaymentDetails/PaymentDetailsList.jsx') +); +const PaymentReceivedRetail = lazy( + () => + import('./Pages/Payment/PaymentReceivedRetail/PaymentReceivedRetail.jsx') +); + +const ExtraChargesList = lazy( + () => import('./Pages/ExtraCharges/ExtraChargesList.jsx') +); + +const BranchLogin = lazy(() => import('./Pages/BranchLogin/BranchLogin.jsx')); +const BackToBranchLogin = lazy( + () => import('./Pages/BranchLogin/BackToBranchLogin.jsx') +); +const Logout = lazy(() => import('./Pages/Logout.jsx')); + +const BacktoLogin = lazy(() => import('./Pages/BranchLogin/BacktoLogin.jsx')); + +const StockPriceUpdate = lazy( + () => import('./Pages/StockPriceUpdate/StockPriceUpdate.jsx') +); + +const ProductCatalogueList = lazy( + () => import('./Pages/ProductCatlogue/ProductcatlogueList.jsx') +); + +const KOT = lazy(() => import('./Pages/Reports/KOT/kot.jsx')); + +const CustomerKOTDisplay = lazy( + () => import('./Pages/Reports/KOT/CustomerKOTDisplay.jsx') +); + +const RedirectApps = lazy(() => import('./Pages/RedirectApps.jsx')); + +const WSTransaction = lazy( + () => import('./Pages/WholeSaleTransaction/WSSalesTransaction.jsx') +); + +const LedgerReport = lazy( + () => import('./Pages/Reports/LedgerReport/LedgerReport.jsx') +); +const PaymentDetailsPage = lazy( + () => + import('./Pages/BookingScreen/Components/BookingFunctionality/PaymentDetailsPage.jsx') +); + +const CreditCustomerPrint = lazy( + () => + import('./Pages/BookingScreen/Components/BookingFunctionality/CreditDownloadpage.jsx') +); + +const Cancellation = lazy( + () => import('./Pages/CancelReschedule/Cancellation.jsx') +); + +const ChangePaymentmode = lazy( + () => import('./Pages/CancelReschedule/ChangePaymentmode.jsx') +); + +const CancellationList = lazy( + () => import('./Pages/CancelReschedule/CancellationList.jsx') +); + +const CancelApplicableProd = lazy( + () => import('./Pages/CancelReschedule/CancelApplicableProd.jsx') +); + +const CancellationListPending = lazy( + () => import('./Pages/CancelReschedule/CancelPendingPayment.jsx') +); + +const AndroidApp = lazy(() => import('./Pages/AndroidApp/AndroidApp.jsx')); + +const EstimateItemWiseReport = lazy( + () => import('./Pages/Reports/Estimate/EstimateItemWiseReport.jsx') +); + +const EstimateDateWiseReport = lazy( + () => import('./Pages/Reports/Estimate/EstimateDateWiseReport.jsx') +); + +const OfferForm = lazy(() => import('./Pages/Offer/Offer/OfferFormNew.jsx')); + +const OfferList = lazy(() => import('./Pages/Offer/Offer/OfferListNew.jsx')); + +const ItemWise = lazy(() => import('./Pages/Offer/ItemOffer/ItemWiseForm.jsx')); +const SalesWiseForm = lazy( + () => import('./Pages/Offer/SalesOffer/SalesWiseForm.jsx') +); +const SalesWiseList = lazy( + () => import('./Pages/Offer/SalesOffer/SalesWiseList.jsx') +); + +const QuantityWise = lazy( + () => import('./Pages/Offer/QuantityOffer/QuantityWiseForm.jsx') +); + +const BuyOneGetOneForm = lazy( + () => import('./Pages/Offer/BuyOneGetOneOffer/BuyOneGetOneForm.jsx') +); + +const LoyaltyPointsList = lazy( + () => import('./Pages/Offer/LoyaltyPoints/LoyaltyPointsList.jsx') +); + +const BundleOfferForm = lazy( + () => import('./Pages/Offer/BundleOffer/BundleOfferForm.jsx') +); +const BundleOfferList = lazy( + () => import('./Pages/Offer/BundleOffer/BundleOfferList.jsx') +); +const CouponWiseOfferlist = lazy( + () => import('./Pages/Offer/CouponOffer/CouponWiseOfferlist.jsx') +); + +const PromocodeList = lazy( + () => import('./Pages/Offer/PromoCode/PromocodeList.jsx') +); + +const OfferCodeList = lazy( + () => import('./Pages/Offer/OfferCode/OfferCodeList.jsx') +); + +const PricingPage = lazy( + () => + import('./Pages/BookingScreen/Components/UtillComponents/PricingPage.jsx') +); + +const PurchaseOrder = lazy( + () => import('./Pages/PurchaseOrder/PurchaseOrder.jsx') +); + +const PurchaseOrderMail = lazy( + () => import('./Pages/PurchaseOrder/PurchaseOrderMail.jsx') +); + +const PurchaseOrderList = lazy( + () => import('./Pages/PurchaseOrder/PurchaseOrderList.jsx') +); + +const StockReceivedList = lazy( + () => import('./Pages/StockTransfer/StockReceivedList.jsx') +); + +const GstInvoiceSetUpForm = lazy( + () => import('./Pages/GstInvoiceSetup/GstInvoiceSetUpForm.jsx') +); + +const gstInvoiceSetUpList = lazy( + () => import('./Pages/GstInvoiceSetup/GstInvoiceSetupList.jsx') +); + +const StockinHand = lazy(() => import('./Pages/StockinHand/StockinHand.jsx')); + +const PurchaseReturn = lazy( + () => import('./Pages/PurchaseReturn/purchaseReturn.jsx') +); + +const PurchaseReturnget = lazy( + () => import('./Pages/PurchaseReturn/PurchaseReturnGet.jsx') +); + +const KioskBookingPage = lazy( + () => import('./Pages/Kiosk/KioskBookingPage.jsx') +); + +const KioskBookingReceipt = lazy( + () => import('./Pages/Kiosk/PaymentGateway/PaymentGatewayReceipt.jsx') +); + +const KioskComponentList = lazy( + () => import('./Pages/KioskComponent/KioskComponentList.jsx') +); + +const CustomerDisplay = lazy( + () => import('./Pages/CustomerDisplay/CustomerDisplay.jsx') +); + +const PurchaseQuotationForm = lazy( + () => import('./Pages/PurchaseQuotation/PurchaseQuotationForm.jsx') +); + +const DeliveryChallanForm = lazy( + () => import('./Pages/DeliveryChallan/Deliverychallan.jsx') +); + +const DeliveryChallanList = lazy( + () => import('./Pages/DeliveryChallan/DeliverychallanList.jsx') +); + +const ComboOfferMaster = lazy( + () => import('./Pages/Offer/ComboOfferPack/ComboOfferForm.jsx') +); + +const PaymentDeviceForm = lazy( + () => import('./Pages/Payment/PaymentDevice/PaymentDeviceForm.jsx') +); +const PaymentFailedDetailsList = lazy( + () => + import('./Pages/Payment/PaymentFailedDetails/PaymentFailedDetailsList.jsx') +); + +const CounterCategoryMappingForm = lazy( + () => import('./Pages/CounterCategoryMapping/CounterCategoryMappingForm.jsx') +); + +const ImageBulkUpload = lazy( + () => import('./Pages/ImageBulkUpload/ImageBulkUpload.jsx') +); + +const WholesaleBookingPage = lazy( + () => import('./Pages/PurchaseScreen/LayoutScreen8/LayoutScreen8.jsx') +); + +const WholeSaleProductList = lazy( + () => import('./Pages/Wholesale/ProductList.jsx') +); + +const ProductEntry = lazy(() => import('./Pages/Wholesale/ProductEntry.jsx')); + +const ProductEntryList = lazy( + () => import('./Pages/Wholesale/ProductEntryList.jsx') +); +const ItemEntry = lazy( + () => import('./Pages/Wholesale/ItemEntry/ItemEntry.jsx') +); + +const WsPreorder = lazy( + () => import('./Pages/Wholesalespreorder/WholesalePreorderList.jsx') +); + +const WsPreorderForm = lazy( + () => import('./Pages/Wholesalespreorder/WholesalePreorderForm.jsx') +); + +const ExtraChrgesList = lazy( + () => import('./Pages/Wholesale/ItemEntry/ExtraChrgesList.jsx') +); + +const SalesBillCancel = lazy( + () => import('./Pages/SalesRemoval/SalesBillCancelList.jsx') +); + +const WholeSaleAbstract = lazy( + () => import('./Pages/WholeSaleAbstract/WholeSaleAbstract.jsx') +); + +const WholeSaleSellerAbstract = lazy( + () => import('./Pages/WholeSaleAbstract/WholeSaleSellerAbstract.jsx') +); + +const PaymentReceived = lazy( + () => import('./Pages/WholeSaleTransaction/PaymentReceived.jsx') +); + +const WholeSaleSalesReport = lazy( + () => import('./Pages/WholeSaleReport/WholeSalesSalesReport.jsx') +); + +const WholeSalePurchaseReport = lazy( + () => import('./Pages/WholeSaleReport/WholeSalePurchaseReport.jsx') +); +const WholeSalePaymentPurchaseReport = lazy( + () => + import('./Pages/WholesalePaymentReport/WholeSalePaymentPurchaseReport.jsx') +); + +const WholeSalePaymentSalesReport = lazy( + () => + import('./Pages/WholesalePaymentReport/WholeSalePaymementSaleReport.jsx') +); + +const SpeechLanguagesList = lazy( + () => import('./Pages/SpeechLanguages/SpeechLanguagesList.jsx') +); + +const LegderList = lazy( + () => import('./Pages/WholeSaleLedger/WholeSaleLedger.jsx') +); + +const SellerMasterTran = lazy( + () => import('./Pages/WholeSaleTransaction/SellerMasterTransaction.jsx') +); + +const TicketForm = lazy(() => import('./Pages/Ticket/TicketForm.jsx')); + +const ThemeCreation = lazy( + () => import('./Pages/BookingScreen/Components/ThemeCreation/ThemeList.jsx') +); + +const ThemeSelection = lazy( + () => + import('./Pages/BookingScreen/Components/ThemeCreation/ThemePreview.jsx') +); + +const BarcodeTemplateSetup = lazy( + () => import('./Pages/BarcodeSetup/BarcodeTemplateSetup.jsx') +); + +const BarcodeComponentList = lazy( + () => import('./Pages/BarcodeComponent/BarcodeComponentList.jsx') +); + +const StoreRecipelist = lazy( + () => import('./Pages/StoreKitchen/StoreRecipe/StoreRecipelist.jsx') +); + +const StoreRecipeform = lazy( + () => import('./Pages/StoreKitchen/StoreRecipe/StoreRecipeform.jsx') +); + +const Storekitchenlist = lazy( + () => import('./Pages/StoreKitchen/StoretoKitchen/StoretoKitchenlist.jsx') +); + +const StoreKitchenform = lazy( + () => import('./Pages/StoreKitchen/StoretoKitchen/Storetokitchenform.jsx') +); import { getSession, sessionStore } from './Services/Others'; import axios from 'axios'; -import KitchenFinishlist from './Pages/StoreKitchen/StoreKitchenFinish/KitchenFinishlist.jsx'; -import KitechenFinishform from './Pages/StoreKitchen/StoreKitchenFinish/KitechenFinishform.jsx'; +const KitchenFinishlist = lazy( + () => import('./Pages/StoreKitchen/StoreKitchenFinish/KitchenFinishlist.jsx') +); +const KitechenFinishform = lazy( + () => import('./Pages/StoreKitchen/StoreKitchenFinish/KitechenFinishform.jsx') +); -import FreeProductList from './Pages/FreeProducts/FreeProduct/FreeProductList.jsx'; -import FreePurchaseEnteryForm from './Pages/FreeProducts/FreePurchase/FreePurchaseEntery/FreePurchaseEnteryForm.jsx'; -import FreePurchaseEnteryList from './Pages/FreeProducts/FreePurchase/FreePurchaseEntery/FreePurchaseEnteryList.jsx'; -import FreePurchaseOrderList from './Pages/FreeProducts/FreePurchase/FreePurchaseOrder/FreePurchaseOrderList.jsx'; -import FreePurchaseOrderForm from './Pages/FreeProducts/FreePurchase/FreePurchaseOrder/FreePurchaseOrderForm.jsx'; -import FreePurchaseReturnList from './Pages/FreeProducts/FreePurchase/FreePurchaseReturn/FreePurchaseReturnList.jsx'; -import FreePurchaseReturnForm from './Pages/FreeProducts/FreePurchase/FreePurchaseReturn/FreePurchaseReturnForm.jsx'; -import CommonForm from './Pages/Offer/LoyaltyPoints/CommonForm.jsx'; -import ReprintReasonReportList from './Pages/Reports/ReprintReasonReport/ReprintReasonReportList.jsx'; -import RevenueItemWiseReport from './Pages/Reports/Revenue/RevenueItemWiseReport.jsx'; -import LinkUrlCreate from './Pages/paymentpdfPage/LinkUrlCreate.jsx'; -import SupplierProductMapping from './Pages/SupplierProductMapping/SupplierProductMapping.jsx'; -import RedirectUserProfile from './Pages/RedirectUserProfile.jsx'; -import RelieveRequestForm from './Pages/EmpMaster/EmpRelieve.jsx'; -import PurchaseQuotationList from './Pages/PurchaseQuotation/PurchaseQuotationList.jsx'; -import ExchangeAndReplacementList from './Pages/ExchangeAndReplacement/ExchangeAndReplacementList.jsx'; -import ExchangeAndReplacementForm from './Pages/ExchangeAndReplacement/ExchangeAndReplacementForm.jsx'; -import ExchangeReturnMapForm from './Pages/ExchangeReturnMap/ExchangeReturnMapForm.jsx'; -import ExchangeReturnMapList from './Pages/ExchangeReturnMap/ExchangeReturnMapList.jsx'; -import OtherServicesForm from './Pages/OtherServices/OtherServicesForm.jsx'; -import OtherServicesList from './Pages/OtherServices/OtherServicesList.jsx'; -import EmpCommisionOrIncentiveForm from './Pages/EmpCommissionOrIncentive/EmpCommisionOrIncentiveForm.jsx'; -import EmpCommisionOrIncentiveList from './Pages/EmpCommissionOrIncentive/EmpCommisionOrIncentiveList.jsx'; -import SalesBillProductsReturnList from './Pages/CancelReschedule/SalesBillProductReturnList.jsx'; -import SalesBillProductsReturn from './Pages/CancelReschedule/SalesBillProductsReturn.jsx'; -import DeliveryChallanToInvoiceForm from './Pages/DeliveryChallanToInvoice/DeliveryChallanToInvoiceForm.jsx'; -import DeliveryChallanToInvoiceList from './Pages/DeliveryChallanToInvoice/DeliveryChallanToInvoiceList.jsx'; -import TipAmountSettlementList from './Pages/Reports/TipAmountSettlement/TipAmountSettlementList.jsx'; -import EmployeeSettlement from './Pages/Reports/EmployeeSettlement/EmployeeSettlement.jsx'; -import PublicQrCode from './Pages/Reports/PublicQrCode.jsx'; -import TableMapping from './Pages/TableMapping/TableMapping.jsx'; -import TableMAppingList from './Pages/TableMapping/TableMAppingList.jsx'; -import PurchaseOrderReport from './Pages/Reports/PurchaseReport/PurchaseOrderReport.jsx'; -import SalesOrder from './Pages/SalesOrder/SalesOrder.jsx'; -import LoyaltyBased from './Pages/Offer/LoyaltyBased/LoyaltyBased.jsx'; -import LoyaltyBasedList from './Pages/Offer/LoyaltyBased/LoyaltyBasedList.jsx'; -import CodeBase from './Pages/Offer/CodeBase/CodeBase.jsx'; -import CodeBaseList from './Pages/Offer/CodeBase/CodeBaseList.jsx'; -import TurboAddForm from './Pages/Product/TurboAddForm.jsx'; -import ProductMaster from './Pages/Product/ProductMaster.jsx'; -import GatewayMasterConfiguration from './Pages/GatewayMasterConfiguration/GatewayMasterConfiguration.jsx'; -import GatewayMasterConfigurationList from './Pages/GatewayMasterConfiguration/GatewayMasterConfigurationList.jsx'; -import MembershipForm from './Pages/Membership/MembershipForm.jsx'; -import MembershipList from './Pages/Membership/MembershipList.jsx'; -import SlotManagementForm from './Pages/SlotManagement/SlotManagement.jsx'; -import SlotManagementList from './Pages/SlotManagement/SlotManagementList.jsx'; -import BookingReScedule from './Pages/CancelReschedule/BookingReScedule.jsx'; -import BookingReSceduleList from './Pages/CancelReschedule/BookingReSceduleList.jsx'; -import MembershipReport from './Pages/Reports/Membership/MembershipReport.jsx'; -import OpeningStock from './Pages/openingStock/openingstockForm.jsx'; -import OpeningStockList from './Pages/openingStock/OpeningStockList.jsx'; -import StockAdjustment from './Pages/StockAdjustment/StockAdjustment.jsx'; -import StockAdjustmentList from './Pages/StockAdjustment/StockAdjustmentList.jsx'; -import TopSellingProducts from './Pages/DashBoard/TopSellingProductsChart.jsx'; -import AutomatedReorder from './Pages/Automated Reorder/AutomatedReorder.jsx'; -import AutomatedReorderList from './Pages/Automated Reorder/AutomatedReorderList.jsx'; -import CustomerPurchaseConfirm from './Pages/PurchaseOrder/CustomerPurchaseConfirm/CustomerPurchaseConfirm.jsx'; -import MenuQRCode from './Pages/Reports/MenuQRCode/MenuQRCode.jsx'; -import CustomerMenuPage from './Pages/Reports/MenuQRCode/CustomerMenuPage.jsx'; -import PurchaseLink from './Pages/PurchaseOrder/CustomerPurchaseConfirm/PurchaseLink.jsx'; -import RackForm from './Pages/Rack/RackForm.jsx'; -import RackList from './Pages/Rack/RackList.jsx'; -import CreateTransfer from './Pages/StockTransfer/CreateTransfer.jsx'; -import Dispatch from './Pages/StockTransfer/Dispatch.jsx'; -import ComboLayout3 from './Pages/BookingScreen/Template/ComboLayout3/ComboLayout3.jsx'; -import StockTransferList from './Pages/StockTransfer/TransferList.jsx'; -import Productcatlogue from './Pages/ProductCatlogue/Productcatalogue.jsx'; +const FreeProductList = lazy( + () => import('./Pages/FreeProducts/FreeProduct/FreeProductList.jsx') +); + +const FreePurchaseEnteryForm = lazy( + () => + import('./Pages/FreeProducts/FreePurchase/FreePurchaseEntery/FreePurchaseEnteryForm.jsx') +); +const FreePurchaseEnteryList = lazy( + () => + import('./Pages/FreeProducts/FreePurchase/FreePurchaseEntery/FreePurchaseEnteryList.jsx') +); + +const FreePurchaseOrderList = lazy( + () => + import('./Pages/FreeProducts/FreePurchase/FreePurchaseOrder/FreePurchaseOrderList.jsx') +); +const FreePurchaseOrderForm = lazy( + () => + import('./Pages/FreeProducts/FreePurchase/FreePurchaseOrder/FreePurchaseOrderForm.jsx') +); + +const FreePurchaseReturnList = lazy( + () => + import('./Pages/FreeProducts/FreePurchase/FreePurchaseReturn/FreePurchaseReturnList.jsx') +); +const FreePurchaseReturnForm = lazy( + () => + import('./Pages/FreeProducts/FreePurchase/FreePurchaseReturn/FreePurchaseReturnForm.jsx') +); +const CommonForm = lazy( + () => import('./Pages/Offer/LoyaltyPoints/CommonForm.jsx') +); + +const ReprintReasonReportList = lazy( + () => + import('./Pages/Reports/ReprintReasonReport/ReprintReasonReportList.jsx') +); + +const RevenueItemWiseReport = lazy( + () => import('./Pages/Reports/Revenue/RevenueItemWiseReport.jsx') +); + +const LinkUrlCreate = lazy( + () => import('./Pages/paymentpdfPage/LinkUrlCreate.jsx') +); + +const SupplierProductMapping = lazy( + () => import('./Pages/SupplierProductMapping/SupplierProductMapping.jsx') +); + +const RedirectUserProfile = lazy( + () => import('./Pages/RedirectUserProfile.jsx') +); + +const RelieveRequestForm = lazy( + () => import('./Pages/EmpMaster/EmpRelieve.jsx') +); + +const PurchaseQuotationList = lazy( + () => import('./Pages/PurchaseQuotation/PurchaseQuotationList.jsx') +); + +const ExchangeAndReplacementList = lazy( + () => import('./Pages/ExchangeAndReplacement/ExchangeAndReplacementList.jsx') +); +const ExchangeAndReplacementForm = lazy( + () => import('./Pages/ExchangeAndReplacement/ExchangeAndReplacementForm.jsx') +); + +const ExchangeReturnMapForm = lazy( + () => import('./Pages/ExchangeReturnMap/ExchangeReturnMapForm.jsx') +); +const ExchangeReturnMapList = lazy( + () => import('./Pages/ExchangeReturnMap/ExchangeReturnMapList.jsx') +); + +const OtherServicesForm = lazy( + () => import('./Pages/OtherServices/OtherServicesForm.jsx') +); +const OtherServicesList = lazy( + () => import('./Pages/OtherServices/OtherServicesList.jsx') +); +const EmpCommisionOrIncentiveForm = lazy( + () => + import('./Pages/EmpCommissionOrIncentive/EmpCommisionOrIncentiveForm.jsx') +); + +const EmpCommisionOrIncentiveList = lazy( + () => + import('./Pages/EmpCommissionOrIncentive/EmpCommisionOrIncentiveList.jsx') +); + +const SalesBillProductsReturnList = lazy( + () => import('./Pages/CancelReschedule/SalesBillProductReturnList.jsx') +); + +const SalesBillProductsReturn = lazy( + () => import('./Pages/CancelReschedule/SalesBillProductsReturn.jsx') +); + +const DeliveryChallanToInvoiceForm = lazy( + () => + import('./Pages/DeliveryChallanToInvoice/DeliveryChallanToInvoiceForm.jsx') +); + +const DeliveryChallanToInvoiceList = lazy( + () => + import('./Pages/DeliveryChallanToInvoice/DeliveryChallanToInvoiceList.jsx') +); + +const TipAmountSettlementList = lazy( + () => + import('./Pages/Reports/TipAmountSettlement/TipAmountSettlementList.jsx') +); + +const EmployeeSettlement = lazy( + () => import('./Pages/Reports/EmployeeSettlement/EmployeeSettlement.jsx') +); +const PublicQrCode = lazy(() => import('./Pages/Reports/PublicQrCode.jsx')); + +const TableMapping = lazy( + () => import('./Pages/TableMapping/TableMapping.jsx') +); +const TableMAppingList = lazy( + () => import('./Pages/TableMapping/TableMAppingList.jsx') +); + +const PurchaseOrderReport = lazy( + () => import('./Pages/Reports/PurchaseReport/PurchaseOrderReport.jsx') +); + +const SalesOrder = lazy(() => import('./Pages/SalesOrder/SalesOrder.jsx')); + +const LoyaltyBased = lazy( + () => import('./Pages/Offer/LoyaltyBased/LoyaltyBased.jsx') +); +const LoyaltyBasedList = lazy( + () => import('./Pages/Offer/LoyaltyBased/LoyaltyBasedList.jsx') +); +const CodeBase = lazy(() => import('./Pages/Offer/CodeBase/CodeBase.jsx')); +const CodeBaseList = lazy( + () => import('./Pages/Offer/CodeBase/CodeBaseList.jsx') +); + +const TurboAddForm = lazy(() => import('./Pages/Product/TurboAddForm.jsx')); + +const ProductMaster = lazy(() => import('./Pages/Product/ProductMaster.jsx')); + +const GatewayMasterConfiguration = lazy( + () => + import('./Pages/GatewayMasterConfiguration/GatewayMasterConfiguration.jsx') +); +const GatewayMasterConfigurationList = lazy( + () => + import('./Pages/GatewayMasterConfiguration/GatewayMasterConfigurationList.jsx') +); + +const MembershipForm = lazy( + () => import('./Pages/Membership/MembershipForm.jsx') +); +const MembershipList = lazy( + () => import('./Pages/Membership/MembershipList.jsx') +); +const SlotManagementForm = lazy( + () => import('./Pages/SlotManagement/SlotManagement.jsx') +); +const SlotManagementList = lazy( + () => import('./Pages/SlotManagement/SlotManagementList.jsx') +); + +const BookingReScedule = lazy( + () => import('./Pages/CancelReschedule/BookingReScedule.jsx') +); +const BookingReSceduleList = lazy( + () => import('./Pages/CancelReschedule/BookingReSceduleList.jsx') +); + +const MembershipReport = lazy( + () => import('./Pages/Reports/Membership/MembershipReport.jsx') +); +const OpeningStock = lazy( + () => import('./Pages/openingStock/openingstockForm.jsx') +); +const OpeningStockList = lazy( + () => import('./Pages/openingStock/OpeningStockList.jsx') +); + +const StockAdjustment = lazy( + () => import('./Pages/StockAdjustment/StockAdjustment.jsx') +); +const StockAdjustmentList = lazy( + () => import('./Pages/StockAdjustment/StockAdjustmentList.jsx') +); +const TopSellingProducts = lazy( + () => import('./Pages/DashBoard/TopSellingProductsChart.jsx') +); + +const AutomatedReorder = lazy( + () => import('./Pages/Automated Reorder/AutomatedReorder.jsx') +); +const AutomatedReorderList = lazy( + () => import('./Pages/Automated Reorder/AutomatedReorderList.jsx') +); + +const CustomerPurchaseConfirm = lazy( + () => + import('./Pages/PurchaseOrder/CustomerPurchaseConfirm/CustomerPurchaseConfirm.jsx') +); + +const MenuQRCode = lazy( + () => import('./Pages/Reports/MenuQRCode/MenuQRCode.jsx') +); + +const PurchaseLink = lazy( + () => import('./Pages/PurchaseOrder/CustomerPurchaseConfirm/PurchaseLink.jsx') +); +const RackForm = lazy(() => import('./Pages/Rack/RackForm.jsx')); +const RackList = lazy(() => import('./Pages/Rack/RackList.jsx')); + +const CreateTransfer = lazy( + () => import('./Pages/StockTransfer/CreateTransfer.jsx') +); +const Dispatch = lazy(() => import('./Pages/StockTransfer/Dispatch.jsx')); +const StockTransferList = lazy( + () => import('./Pages/StockTransfer/TransferList.jsx') +); + +const ComboLayout3 = lazy( + () => import('./Pages/BookingScreen/Template/ComboLayout3/ComboLayout3.jsx') +); + +const Productcatlogue = lazy( + () => import('./Pages/ProductCatlogue/Productcatalogue.jsx') +); const subDirectory = import.meta.env.BASE_URL; const apiCommonUrl = import.meta.env.ENV_API_URL_COMMON; @@ -268,7 +732,7 @@ const fetchComponent = async () => { sessionStore('userName', 'Karthiga'); sessionStorage.setItem( 'auth', - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiOTM2MDY0MjI0NCIsIlBhc3N3b3JkIjoiWkB6MTIzNCIsImF1ZCI6WyJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMTMiLCJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMTIiLCJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMTQiLCJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMTMiXSwiZXhwIjoxNzcwMjMzMDA3LCJpc3MiOiJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMDEifQ.y6ZLDB3qz1nJk68XY13jXxHKd99LVX2GhzhtE5eGXqI' + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiOTM2MDY0MjI0NCIsIlBhc3N3b3JkIjoiWkB6MTIzNCIsImF1ZCI6WyJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMTMiLCJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMTIiLCJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMTQiLCJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMTMiXSwiZXhwIjoxNzcwNzQ5MjkxLCJpc3MiOiJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMDEifQ.aXnhbA3ReRVyt8denDX_LK_ecVBiG5KdeHsurVR7iwQ' ); const AppId = getSession('AppId'); @@ -373,7 +837,7 @@ const fetchHomeComponent = async () => { sessionStore('userName', 'Karthiga'); sessionStorage.setItem( 'auth', - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiOTM2MDY0MjI0NCIsIlBhc3N3b3JkIjoiWkB6MTIzNCIsImF1ZCI6WyJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMTMiLCJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMTIiLCJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMTQiLCJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMTMiXSwiZXhwIjoxNzcwMjMzMDA3LCJpc3MiOiJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMDEifQ.y6ZLDB3qz1nJk68XY13jXxHKd99LVX2GhzhtE5eGXqI' + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiOTM2MDY0MjI0NCIsIlBhc3N3b3JkIjoiWkB6MTIzNCIsImF1ZCI6WyJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMTMiLCJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMTIiLCJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMTQiLCJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMTMiXSwiZXhwIjoxNzcwNzQ5MjkxLCJpc3MiOiJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMDEifQ.aXnhbA3ReRVyt8denDX_LK_ecVBiG5KdeHsurVR7iwQ' ); const AppId = getSession('AppId'); @@ -1087,8 +1551,6 @@ export const routesConfig = [ empAccess: 'Product Receipt', }, - - { path: 'receive-stocks', component: StockReceivedList, @@ -1228,7 +1690,6 @@ export const routesConfig = [ empAccess: 'DC to Invoice', }, - { path: 'shift-master', component: ShiftMasterList, empAccess: 'Shift' }, { path: 'shift-master/new', diff --git a/src/useSessionManager.js b/src/useSessionManager.js new file mode 100644 index 0000000..85b6ec1 --- /dev/null +++ b/src/useSessionManager.js @@ -0,0 +1,72 @@ +import { useEffect, useState } from 'react'; +import { useDispatch } from 'react-redux'; +import { + checkSession, + GenerateLogout, +} from './Features/BrachLogin/BranchLogin.js'; +import { + clearSession, + getSession, + TokendecryptedValuesFun, +} from './Services/Others.js'; +const commonSubDir = import.meta.env.ENV_COMMON_BASE_URL; + +const useSessionManager = (dependencyTrigger) => { + const dispatch = useDispatch(); + const [sessionData, setSessionData] = useState(null); + + // 🔹 Load session + useEffect(() => { + const CompId = getSession('CompId'); + const AppId = getSession('AppId'); + const BranchId = getSession('BranchId'); + const UserType = getSession('UserType'); + + if (CompId && AppId && BranchId) { + setSessionData({ CompId, AppId, BranchId, UserType }); + } + }, []); + + // 🔹 Session validity check (same logic, centralized) + useEffect(() => { + const sessionCheckFun = async () => { + const UserId = getSession('UserId'); + const sessionId = getSession('SessionId'); + const IsLogout = getSession('Mode'); + + let encryptedLoginType = TokendecryptedValuesFun( + sessionStorage.getItem('LoginType') + ); + + if (encryptedLoginType !== 'Kiosk') { + const res = await dispatch( + checkSession({ UserId, sessionId }) + ).unwrap(); + if (res?.data?.statusCode === 1 && res?.data?.response === 'False') { + if (IsLogout !== 'Logout') { + alert('Session invalid. Redirecting to login...'); + } + clearSession(); + window.location.replace(commonSubDir); + } + } + }; + + sessionCheckFun(); + }, [dependencyTrigger]); + + // 🔹 Logout (shared everywhere) + const logout = async () => { + const UserId = getSession('UserId'); + try { + await dispatch(GenerateLogout({ UserId, status: 'N' })).unwrap(); + } finally { + sessionStorage.clear(); + window.location.replace(commonSubDir); + } + }; + + return { sessionData, logout }; +}; + +export default useSessionManager; diff --git a/src/useSubscriptionManager.js b/src/useSubscriptionManager.js new file mode 100644 index 0000000..b2ffd99 --- /dev/null +++ b/src/useSubscriptionManager.js @@ -0,0 +1,55 @@ +import { useEffect, useRef, useState } from 'react'; +import { useDispatch } from 'react-redux'; +import { + ChangeAppExpDateData, + changeHeightforExpDate, + getAppSubscriptionDate, +} from './Features/BookingScreen/BookingData/BookingData.js'; + +const useSubscriptionManager = (sessionData, logout) => { + const dispatch = useDispatch(); + const prevRemainingDays = useRef(null); + const [remainingDays, setRemainingDays] = useState(null); + + useEffect(() => { + if (!sessionData) return; + + const fetchExpDate = async () => { + const { CompId, AppId, BranchId, UserType } = sessionData; + + const res = await dispatch( + getAppSubscriptionDate({ CompId, BranchId, AppId }) + ).unwrap(); + + const expData = res?.data?.data?.[0]; + if (!expData) return logout(); + + if (prevRemainingDays.current !== expData.RemainingDays) { + prevRemainingDays.current = expData.RemainingDays; + + setRemainingDays(expData.RemainingDays); + dispatch(ChangeAppExpDateData(expData)); + dispatch(changeHeightforExpDate(expData.RemainingDays)); + + if ( + expData.RemainingDays < 1 && + expData.RemainingHours < 1 && + expData.RemainingMinutes < 1 && + expData.RemainingSeconds < 1 && + UserType !== 'Super Admin' + ) { + alert('Subscription expired'); + logout(); + } + } + }; + + fetchExpDate(); + const interval = setInterval(fetchExpDate, 60 * 60 * 1000); + return () => clearInterval(interval); + }, [sessionData]); + + return remainingDays; +}; + +export default useSubscriptionManager;