From e69d2844ff110b89ef26a52ec5e1b28aef019a9a Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 25 Mar 2026 14:06:01 +0530 Subject: [PATCH] tax, layout card, access based menu warehouse bug fix --- src/App.jsx | 85 +++++++----------- .../BookingScreen/BookingData/BookingData.js | 16 ++-- .../BSCategories/BSCategoryHorizontal.jsx | 82 +++++++++--------- .../LayoutSubCategoryFetcher.jsx | 9 ++ src/Pages/OtherServices/OtherServicesForm.jsx | 6 +- src/utils/useDevToolsDetection.js | 86 ------------------- 6 files changed, 95 insertions(+), 189 deletions(-) delete mode 100644 src/utils/useDevToolsDetection.js diff --git a/src/App.jsx b/src/App.jsx index f746608..0aaeab3 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -26,7 +26,6 @@ import useSubscriptionManager from './useSubscriptionManager.js'; import useSessionManager from './useSessionManager.js'; import ExtendSubscriptionModal from './Pages/ExtentedModal/ExtendSubscriptionModal.jsx'; import devtools from 'devtools-detect'; -import { useDevToolsDetection } from './utils/useDevToolsDetection.js'; const isCapacitor = () => !!window.Capacitor?.isNativePlatform?.(); @@ -172,66 +171,46 @@ const AppRoutes = () => { }; }, [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); + 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); + setTimeout(() => { + window.location.reload(); + }, 100); - // clearInterval(checkDevTools); - // } + clearInterval(checkDevTools); + } - // if (!devtools.isOpen) { - // let before = performance.now(); + if (!devtools.isOpen) { + let before = performance.now(); - // let after = performance.now(); + let after = performance.now(); - // let executionDelay = after - before; + let executionDelay = after - before; - // if (executionDelay > 100) { - // setDevToolsOpen(true); - // document.body.innerHTML = - // "

Close Inspect to continue using the application.

"; - // } else { - // setDevToolsOpen(false); - // } - // } - // }, 1000); + if (executionDelay > 100) { + setDevToolsOpen(true); + document.body.innerHTML = + "

Close Inspect to continue using the application.

"; + } else { + setDevToolsOpen(false); + } + } + }, 1000); - // return () => clearInterval(checkDevTools); - // }, [devToolsOpen]); - const isBlocked = useDevToolsDetection(() => { - // optional: log, notify, etc. - console.warn('DevTools detected'); - }); + return () => clearInterval(checkDevTools); + }, [devToolsOpen]); - if (isBlocked) { - return ( -
-

- DevTools detected. Please close it to continue. -

-
- ); - } if (extendModel) { return ( { - if (action?.payload?.data?.statusCode === 1) { - state.AppExpDateData = - action?.payload?.data?.data?.[0]|| {}; - } else { - state.AppExpDateData = {}; - } + builder.addCase(getAppSubscriptionDate.fulfilled, (state, action) => { + if (action?.payload?.data?.statusCode === 1) { + state.AppExpDateData = + action?.payload?.data?.data?.[0] || {}; + } else { + state.AppExpDateData = {}; + } }); - + }, }); diff --git a/src/Pages/BookingScreen/Components/BSCategories/BSCategoryHorizontal.jsx b/src/Pages/BookingScreen/Components/BSCategories/BSCategoryHorizontal.jsx index 459e1ad..60537fc 100644 --- a/src/Pages/BookingScreen/Components/BSCategories/BSCategoryHorizontal.jsx +++ b/src/Pages/BookingScreen/Components/BSCategories/BSCategoryHorizontal.jsx @@ -534,10 +534,14 @@ function BSCategoryHorizontal(props) { } } else { // 2 or more items, always show - setSubCat(true); + if (FavSelected) { + setSubCat(false); + } else { + setSubCat(true); + } } } - }, [SubcategorieData, templateData]); + }, [SubcategorieData, templateData, FavSelected]); useEffect(() => { if (typeof searchData === 'string' && categoryData?.length > 0) { @@ -608,9 +612,9 @@ function BSCategoryHorizontal(props) { AppId: AppId, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; @@ -647,9 +651,9 @@ function BSCategoryHorizontal(props) { AppId: AppId, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; let res = await dispatch(getSelectedFavItems(data)).unwrap(); @@ -886,9 +890,9 @@ function BSCategoryHorizontal(props) { backgroundColor: !accessOther && accessToCard ? lightenColor( - SelectedCatgColor?.['BackgroundColor'], - 0.4 - ) + SelectedCatgColor?.['BackgroundColor'], + 0.4 + ) : SelectedCatgColor?.['BackgroundColor'], padding: padding, border: accessToCard ? '1px solid' : undefined, @@ -899,9 +903,9 @@ function BSCategoryHorizontal(props) { : SelectedCatgColor?.['BackgroundColor'] === '#000000' ? '#ffffff' : darkenColor( - SelectedCatgColor?.['BackgroundColor'], - 70 - ) + SelectedCatgColor?.['BackgroundColor'], + 70 + ) : undefined, }} className="sampleCard" @@ -935,9 +939,9 @@ function BSCategoryHorizontal(props) { backgroundColor: !accessOther && !accessToCard && -2 == indexval ? lightenColor( - SelectedCatgColor?.['BackgroundColor'], - 0.4 - ) + SelectedCatgColor?.['BackgroundColor'], + 0.4 + ) : SelectedCatgColor?.['BackgroundColor'], padding: padding, border: @@ -983,9 +987,9 @@ function BSCategoryHorizontal(props) { ? index != indexval ? SelectedCatgColor?.['BackgroundColor'] : lightenColor( - SelectedCatgColor?.['BackgroundColor'], - 0.4 - ) + SelectedCatgColor?.['BackgroundColor'], + 0.4 + ) : SelectedCatgColor?.['BackgroundColor'], padding: padding, border: '1px solid', @@ -1088,11 +1092,11 @@ function BSCategoryHorizontal(props) { ? index !== indexval ? SelectedCatgColor?.['BackgroundColor'] : lightenColor( - SelectedCatgColor?.[ - 'BackgroundColor' - ], - 0.4 - ) + SelectedCatgColor?.[ + 'BackgroundColor' + ], + 0.4 + ) : SelectedCatgColor?.['BackgroundColor'], padding: padding, border: '1px solid', @@ -1100,18 +1104,18 @@ function BSCategoryHorizontal(props) { index !== indexval ? SelectedCatgColor?.['BackgroundColor'] : SelectedCatgColor?.['BackgroundColor'] === - '#ffffff' + '#ffffff' ? '#000000' : SelectedCatgColor?.[ - 'BackgroundColor' - ] === '#000000' + 'BackgroundColor' + ] === '#000000' ? '#ffffff' : darkenColor( - SelectedCatgColor?.[ - 'BackgroundColor' - ], - 70 - ), + SelectedCatgColor?.[ + 'BackgroundColor' + ], + 70 + ), userSelect: 'none', minWidth: 'max-content', // set a width if needed }} @@ -1170,16 +1174,16 @@ function BSCategoryHorizontal(props) { backgroundColor: !accessOther && accessToCard ? lightenColor( - SelectedCatgColor?.['BackgroundColor'], - 0.4 - ) + SelectedCatgColor?.['BackgroundColor'], + 0.4 + ) : SelectedCatgColor?.['BackgroundColor'], padding: padding, border: accessToCard && '1px solid', borderColor: accessToCard && - !accessOther && - SelectedCatgColor?.['BackgroundColor'] == '#ffffff' + !accessOther && + SelectedCatgColor?.['BackgroundColor'] == '#ffffff' ? '#000000' : SelectedCatgColor?.['BackgroundColor'] === '#000000' ? '#ffffff' @@ -1219,7 +1223,7 @@ function BSCategoryHorizontal(props) { border: accessOther && '1px solid', borderColor: accessOther && - SelectedCatgColor?.['BackgroundColor'] == '#ffffff' + SelectedCatgColor?.['BackgroundColor'] == '#ffffff' ? '#000000' : SelectedCatgColor?.['BackgroundColor'] === '#000000' ? '#ffffff' diff --git a/src/Pages/BookingScreen/LayoutSubCategoryFetcher.jsx b/src/Pages/BookingScreen/LayoutSubCategoryFetcher.jsx index ca47f77..7369e40 100644 --- a/src/Pages/BookingScreen/LayoutSubCategoryFetcher.jsx +++ b/src/Pages/BookingScreen/LayoutSubCategoryFetcher.jsx @@ -1,7 +1,9 @@ import { useEffect } from 'react'; import { useSelector, useDispatch, shallowEqual } from 'react-redux'; import { + ChangeSubcategoryData, getLayoutSubCategories, + GlobalisFavClicked, GlobalProductCategorie, } from '../../Features/BookingScreen/BookingData/BookingData'; import { getTemplateData } from '../../Features/ThemeChange/ThemeChange'; @@ -12,6 +14,7 @@ const LayoutSubCategoryFetcher = () => { const ProdCat = useSelector(GlobalProductCategorie, shallowEqual); const templateData = useSelector(getTemplateData, shallowEqual); + const favSelected = useSelector(GlobalisFavClicked); const CompId = getSession('CompId'); const BranchId = getSession('BranchId'); @@ -23,6 +26,11 @@ const LayoutSubCategoryFetcher = () => { const isCategory5 = templateData?.BookingCategory?.[0] === 'Category5'; const isLayout2 = templateData?.BookingLayout?.[0] === 'Layout2'; + if (favSelected) { + dispatch(ChangeSubcategoryData([])); + return + } + if (isCategory5 && isLayout2) { dispatch( getLayoutSubCategories({ @@ -37,6 +45,7 @@ const LayoutSubCategoryFetcher = () => { ProdCat, templateData?.BookingCategory?.[0], templateData?.BookingLayout?.[0], + favSelected ]); return null; // this component renders nothing diff --git a/src/Pages/OtherServices/OtherServicesForm.jsx b/src/Pages/OtherServices/OtherServicesForm.jsx index d6b4493..bd32f2f 100644 --- a/src/Pages/OtherServices/OtherServicesForm.jsx +++ b/src/Pages/OtherServices/OtherServicesForm.jsx @@ -49,7 +49,7 @@ const OtherServices = ({ formType }) => { const AppId = getSession('AppId'); const UserId = getSession('UserId'); - console.log(SelectedCategory, 'SelectedCategory'); + console.log(TaxData, 'TaxData'); const items = [ { name: 'Home', @@ -435,8 +435,8 @@ const OtherServices = ({ formType }) => { ({ - value: option.TaxId, - label: option.TaxIdName, + value: option?.TaxId, + label: `${option?.TaxIdName} - ${option?.TaxPercentage}%`, })), ]} label="Tax" diff --git a/src/utils/useDevToolsDetection.js b/src/utils/useDevToolsDetection.js deleted file mode 100644 index 51265e0..0000000 --- a/src/utils/useDevToolsDetection.js +++ /dev/null @@ -1,86 +0,0 @@ -const DevToolsDetector = { - checkWindowSize() { - const threshold = 160; - return ( - window.outerWidth - window.innerWidth > threshold || - window.outerHeight - window.innerHeight > threshold - ); - }, - - checkConsole() { - let detected = false; - const element = new Image(); - Object.defineProperty(element, 'id', { - get: () => { detected = true; } - }); - console.log('%c', element); - console.clear(); - return detected; - }, - - checkDebugger() { - if (import.meta.env.DEV) return false; - const start = performance.now(); - // eslint-disable-next-line no-debugger - debugger; - const end = performance.now(); - return end - start > 100; - }, - - checkToString() { - let detected = false; - const div = document.createElement('div'); - Object.defineProperty(div, 'id', { - get: function () { - detected = true; - return 'id'; - } - }); - console.log(div); - console.clear(); - return detected; - }, - - detect() { - return ( - this.checkWindowSize() || - this.checkConsole() || - this.checkDebugger() || - this.checkToString() - ); - } -}; - -export default DevToolsDetector; - - - -import { useEffect, useState } from 'react'; - -const isMobileOrIOS = () => - /iPhone|iPad|iPod|Android/i.test(navigator.userAgent); - -export const useDevToolsDetection = (onDetected) => { - const [isBlocked, setIsBlocked] = useState(false); - - useEffect(() => { - if (isMobileOrIOS()) return; - - const interval = setInterval(() => { - const detected = DevToolsDetector.detect(); - - if (detected && !isBlocked) { - setIsBlocked(true); - onDetected?.(); - } else if (!detected && isBlocked) { - setIsBlocked(false); - clearInterval(interval); - setTimeout(() => window.location.reload(), 100); - } - }, 1000); - - return () => clearInterval(interval); - }, [isBlocked]); - - return isBlocked; -}; \ No newline at end of file