diff --git a/src/App.jsx b/src/App.jsx index c30c163..a53f14e 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,4 +1,4 @@ -import { useEffect, lazy, Suspense, useRef } from 'react'; +import { useEffect, lazy, Suspense, useRef, useState } from 'react'; import { useLocation, useNavigate } from 'react-router-dom'; import { App as CapacitorApp } from '@capacitor/app'; import { Routes, Route } from 'react-router-dom'; @@ -26,6 +26,7 @@ import WeightScaleApp from './Pages/BookingScreen/WeightscaleApp.jsx'; import useSubscriptionManager from './useSubscriptionManager.js'; import useSessionManager from './useSessionManager.js'; import ExtendSubscriptionModal from './Pages/ExtentedModal/ExtendSubscriptionModal.jsx'; +import devtools from 'devtools-detect'; const isCapacitor = () => !!window.Capacitor?.isNativePlatform?.(); @@ -51,7 +52,7 @@ const AppRoutes = () => { } = useSubscriptionManager(sessionData, logout); const location = useLocation(); const navigate = useNavigate(); - + const [devToolsOpen, setDevToolsOpen] = useState(false); // ✅ Flag to prevent stack push when back button navigates const isBackNav = useRef(false); @@ -188,7 +189,47 @@ const AppRoutes = () => { } catch (err) {} }; }, [navigate, location.pathname, location.search]); - +// 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]); if (extendModel) { return ( import('../BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle1.jsx') -); -const PrintStyle2 = lazy( - () => import('../BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle2.jsx') -); -const PrintStyle3 = lazy( - () => import('../BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle3.jsx') -); -const PrintStyle4 = lazy( - () => import('../BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle4.jsx') -); -const PrintStyle5 = lazy( - () => import('../BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle5.jsx') -); -const PrintStyle6 = lazy( - () => import('../BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle6.jsx') -); -const PrintStyle7 = lazy( - () => import('../BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle7.jsx') -); -const PrintStyle8 = lazy( - () => import('../BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle8.jsx') -); -const PrintStyle9 = lazy( - () => import('../BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle9.jsx') -); -const PrintStyle10 = lazy( - () => - import('../BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle10.jsx') -); -const PrintStyle11 = lazy( - () => - import('../BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle11.jsx') -); -const PrintStyle12 = lazy( - () => - import('../BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle12.jsx') -); -const PrintA4Style11 = lazy( - () => import('../BookingScreen/PrintTemplates/A4/PrintA4Style11.jsx') -); -const PrintA5Style11 = lazy( - () => import('../BookingScreen/PrintTemplates/A4/PrintStyleA5.jsx') -); -const A4Standard = lazy( - () => import('../BookingScreen/PrintTemplates/A4/A4Standard.jsx') -); -const TaxInvoice = lazy( - () => import('../BookingScreen/PrintTemplates/A4/TaxInvoice.jsx') -); +// js Files +import PrintStyle1 from '../BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle1.jsx'; +import PrintStyle2 from '../BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle2.jsx'; +import PrintStyle3 from '../BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle3.jsx'; +import PrintStyle4 from '../BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle4.jsx'; +import PrintStyle5 from '../BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle5.jsx'; +import PrintStyle6 from '../BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle6.jsx'; +import PrintStyle7 from '../BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle7.jsx'; +import PrintStyle8 from '../BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle8.jsx'; +import PrintStyle9 from '../BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle9.jsx'; +import PrintStyle10 from '../BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle10.jsx'; +import PrintStyle11 from '../BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle11.jsx'; +import PrintStyle12 from '../BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle12.jsx'; + +import PrintA4Style11 from '../BookingScreen/PrintTemplates/A4/PrintA4Style11.jsx'; +import PrintA5Style11 from '../BookingScreen/PrintTemplates/A4/PrintStyleA5.jsx'; +import A4Standard from '../BookingScreen/PrintTemplates/A4/A4Standard.jsx'; +import TaxInvoice from '../BookingScreen/PrintTemplates/A4/TaxInvoice.jsx'; + const PaymentPdfBooking = ({ index, orderId, diff --git a/src/utils/useTemplate.js b/src/utils/useTemplate.js index 5bb25ad..349ea7a 100644 --- a/src/utils/useTemplate.js +++ b/src/utils/useTemplate.js @@ -1,6 +1,6 @@ import { useEffect } from 'react'; import { useDispatch } from 'react-redux'; -import { getTemplate } from '../Features/ThemeChange/ThemeChange.js'; +import { getPrintSelectionComponentData, getTemplate } from '../Features/ThemeChange/ThemeChange.js'; export const useTemplate = (CompId, BranchId, AppId) => { @@ -9,7 +9,9 @@ export const useTemplate = (CompId, BranchId, AppId) => { useEffect(() => { const fetchTemplate = async () => { try { + const Data = { AppId, CompId, BranchId }; await dispatch(getTemplate({ CompId, BranchId, AppId })).unwrap(); + dispatch(getPrintSelectionComponentData(Data)).unwrap(); } catch (error) { console.error('Failed to fetch template:', error); }