Merge pull request 'tax, layout card, access based menu warehouse bug fix' (#310) from bug-fix-250326 into main
Reviewed-on: Pozomind/pozo-retail-app#310
This commit is contained in:
commit
4f3cc45eb7
85
src/App.jsx
85
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 =
|
||||
// "<h1 style='color: red; text-align: center;'>Close Inspect to continue using the application.</h1>";
|
||||
// } 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 =
|
||||
"<h1 style='color: red; text-align: center;'>Close Inspect to continue using the application.</h1>";
|
||||
} 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 =
|
||||
// "<h1 style='color: red; text-align: center;'>Close Inspect to continue using the application.</h1>";
|
||||
// } else {
|
||||
// setDevToolsOpen(false);
|
||||
// }
|
||||
// }
|
||||
// }, 1000);
|
||||
if (executionDelay > 100) {
|
||||
setDevToolsOpen(true);
|
||||
document.body.innerHTML =
|
||||
"<h1 style='color: red; text-align: center;'>Close Inspect to continue using the application.</h1>";
|
||||
} 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 (
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
height: '100vh',
|
||||
flexDirection: 'column',
|
||||
gap: '1rem'
|
||||
}}>
|
||||
<h1 style={{ color: 'red' }}>
|
||||
DevTools detected. Please close it to continue.
|
||||
</h1>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
if (extendModel) {
|
||||
return (
|
||||
<ExtendSubscriptionModal
|
||||
|
|
|
|||
|
|
@ -2160,13 +2160,13 @@ const BookingData = createSlice({
|
|||
state.getmultipleSearchDatas = [];
|
||||
}
|
||||
});
|
||||
builder.addCase(getAppSubscriptionDate.fulfilled, (state, action) => {
|
||||
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 = {};
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 }) => {
|
|||
<DropDowns
|
||||
options={[
|
||||
...TaxData?.map((option) => ({
|
||||
value: option.TaxId,
|
||||
label: option.TaxIdName,
|
||||
value: option?.TaxId,
|
||||
label: `${option?.TaxIdName} - ${option?.TaxPercentage}%`,
|
||||
})),
|
||||
]}
|
||||
label="Tax"
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
Loading…
Reference in New Issue