Retail capacitorplugin changes

This commit is contained in:
Karthikalakshmi 2026-04-10 17:41:59 +05:30
parent ddeed6d14a
commit 44ccf80cf7
11 changed files with 418 additions and 293 deletions

View File

@ -93,7 +93,7 @@
); );
} }
</script> </script>
<script src="https://cdn.jsdelivr.net/npm/eruda"></script> <!-- <script src="https://cdn.jsdelivr.net/npm/eruda"></script>
<script src="https://cdn.jsdelivr.net/npm/eruda-network"></script> <script src="https://cdn.jsdelivr.net/npm/eruda-network"></script>
<script> <script>
(function () { (function () {
@ -141,7 +141,7 @@
} }
}, 2000); }, 2000);
})(); })();
</script> </script> -->
<style> <style>
/* ============================================ /* ============================================

View File

@ -9,13 +9,14 @@ import { isMobile, isIOS } from 'react-device-detect';
import { routesConfig } from './routesConfig'; import { routesConfig } from './routesConfig';
import { GlobalItemCard } from './Features/BookingScreen/BookingData/BookingData.js'; import { GlobalItemCard } from './Features/BookingScreen/BookingData/BookingData.js';
import { clearSession, getSession, sessionStore } from './Services/Others.js'; import { clearSession, getSession, sessionStore } from './Services/Others.js';
import KisokSelBooking from './Pages/SelfBooking/KisokSelBooking';
const KisokSelBooking = lazy( import IndividualBooking from './Pages/SelfBooking/IndividualBooking';
() => import('./Pages/SelfBooking/KisokSelBooking') // const KisokSelBooking = lazy(
); // () => import('./Pages/SelfBooking/KisokSelBooking')
const IndividualBooking = lazy( // );
() => import('./Pages/SelfBooking/IndividualBooking') // const IndividualBooking = lazy(
); // () => import('./Pages/SelfBooking/IndividualBooking')
// );
const commonSubDir = import.meta.env.ENV_COMMON_BASE_URL; const commonSubDir = import.meta.env.ENV_COMMON_BASE_URL;
const subDirectory = import.meta.env.ENV_BASE_URL; const subDirectory = import.meta.env.ENV_BASE_URL;
@ -27,9 +28,9 @@ import useSessionManager from './useSessionManager.js';
import ExtendSubscriptionModal from './Pages/ExtentedModal/ExtendSubscriptionModal.jsx'; import ExtendSubscriptionModal from './Pages/ExtentedModal/ExtendSubscriptionModal.jsx';
import devtools from 'devtools-detect'; import devtools from 'devtools-detect';
import { Capacitor } from '@capacitor/core'; import { Capacitor } from '@capacitor/core';
import { addBackButtonListener, isCapacitor, minimizeApp } from './Services/CapacitorService.js';
// const isCapacitor = () => !!window.Capacitor?.isNativePlatform?.(); // const isCapacitor = () => !!window.Capacitor?.isNativePlatform?.();
const isCapacitor = () => Capacitor.isNativePlatform();
// Define your home/exit pages here // Define your home/exit pages here
const HOME_PAGES = [ const HOME_PAGES = [
'/app-page/home', // android minimize '/app-page/home', // android minimize
@ -55,7 +56,6 @@ const AppRoutes = () => {
const [devToolsOpen, setDevToolsOpen] = useState(false); const [devToolsOpen, setDevToolsOpen] = useState(false);
// Flag to prevent stack push when back button navigates // Flag to prevent stack push when back button navigates
const isBackNav = useRef(false); const isBackNav = useRef(false);
console.log(isCapacitor(), 'Is Capacitor');
// Build navigation stack // Build navigation stack
useEffect(() => { useEffect(() => {
// Skip pushing to stack when back button caused this navigation // Skip pushing to stack when back button caused this navigation
@ -80,7 +80,7 @@ const AppRoutes = () => {
sessionStore('navStack', JSON.stringify(stack)); sessionStore('navStack', JSON.stringify(stack));
console.log('📍 Stack:', stack); console.log('📍 Stack:', stack);
} }
} catch (e) { } } catch (e) {}
}, [location.pathname, location.search]); }, [location.pathname, location.search]);
// Web block browser back button // Web block browser back button
@ -91,7 +91,7 @@ const AppRoutes = () => {
const currentPath = location.pathname; const currentPath = location.pathname;
const SessionId = getSession('SessionId'); const SessionId = getSession('SessionId');
console.log('SessionId:', SessionId, 'CurrentPath:', currentPath) console.log('SessionId:', SessionId, 'CurrentPath:', currentPath);
// 🟢 If session exists allow navigation // 🟢 If session exists allow navigation
if (SessionId) { if (SessionId) {
console.log('Browser back allowed'); console.log('Browser back allowed');
@ -114,11 +114,13 @@ const AppRoutes = () => {
// Android Capacitor back button // Android Capacitor back button
useEffect(() => { useEffect(() => {
if (!isCapacitor()) return; if (!isCapacitor()) return;
const handler = async () => { const handler = async () => {
try { try {
const currentPath = window.location.pathname + window.location.search; // Bug 2 fix
const currentPath = window.location.pathname + window.location.search;
const raw = getSession('navStack'); const raw = getSession('navStack');
let stack = raw ? JSON.parse(raw) : []; let stack = raw ? JSON.parse(raw) : [];
@ -130,36 +132,43 @@ const AppRoutes = () => {
if (stack.length > 0) { if (stack.length > 0) {
const previous = stack[stack.length - 1]; const previous = stack[stack.length - 1];
sessionStore('navStack', JSON.stringify(stack)); sessionStore('navStack', JSON.stringify(stack));
isBackNav.current = true; // Bug 3 fix BEFORE navigate isBackNav.current = true;
navigate(previous); navigate(previous);
return; return;
} }
if (HOME_PAGES?.some((p) => currentPath?.includes(p))) { if (HOME_PAGES?.some((p) => currentPath?.includes(p))) {
await CapacitorApp.minimizeApp(); await minimizeApp();
return; return;
} }
if (LOGIN_PAGES?.some((p) => currentPath?.includes(p))) { if (LOGIN_PAGES?.some((p) => currentPath?.includes(p))) {
await CapacitorApp.minimizeApp(); await minimizeApp();
return; return;
} }
const home = '/app-page/home'; const home = '/app-page/home';
isBackNav.current = true; // Bug 3 fix here too isBackNav.current = true;
sessionStore('navStack', JSON.stringify([home])); sessionStore('navStack', JSON.stringify([home]));
navigate(home); navigate(home);
} catch (e) { } catch (e) {
console.error('Back handler error:', e); console.error("Back handler error:", e);
await CapacitorApp.minimizeApp(); await minimizeApp();
} }
}; };
const listenerPromise = CapacitorApp.addListener('backButton', handler); // Bug 1 fix let listener;
addBackButtonListener(handler).then((l) => {
listener = l;
});
return () => { return () => {
listenerPromise.then(({ remove }) => remove()); if (listener) listener.remove();
}; };
}, [navigate,location.pathname, location.search]);
}, [navigate, location.pathname, location.search]);
// mohan // mohan
// useEffect(() => { // useEffect(() => {
// if (isMobile || isIOS) { // if (isMobile || isIOS) {
@ -200,7 +209,7 @@ const AppRoutes = () => {
// return () => clearInterval(checkDevTools); // return () => clearInterval(checkDevTools);
// }, [devToolsOpen]); // }, [devToolsOpen]);
if (extendModel) { if (extendModel) {
return ( return (
<ExtendSubscriptionModal <ExtendSubscriptionModal

View File

@ -825,7 +825,7 @@ const AppPage = () => {
// featureaddDetails?.find( // featureaddDetails?.find(
// (item) => item?.FeatureAddonName?.toLowerCase() === 'kiosk sales' // (item) => item?.FeatureAddonName?.toLowerCase() === 'kiosk sales'
// ) && // ) &&
getsubItem('Self Booking QR Code', `${subDirectory}report/PublicQrCode`), getsubItem('Self Booking Qr Code', `${subDirectory}report/PublicQrCode`),
DineinData && dinePreference DineinData && dinePreference
? getsubItem('Table Mapping', `${subDirectory}setting/TableMapping`) ? getsubItem('Table Mapping', `${subDirectory}setting/TableMapping`)
: '', : '',
@ -840,8 +840,8 @@ const AppPage = () => {
const superAdminUserKOTMenu = const superAdminUserKOTMenu =
DineinData && dinePreference DineinData && dinePreference
? [ ? [
getsubItem('KOT', `${subDirectory}kitchen/kot`), getsubItem('Kot', `${subDirectory}kitchen/kot`),
getsubItem('KOT Display', `${subDirectory}kitchen/kot-display`), getsubItem('Kot Display', `${subDirectory}kitchen/kot-display`),
] ]
: []; : [];
@ -1301,7 +1301,13 @@ const AppPage = () => {
getsubItem('Reprint Details', `${subDirectory}report/reprintreasonreport`), getsubItem('Reprint Details', `${subDirectory}report/reprintreasonreport`),
sportsAppPreference && sportsAppPreference &&
getsubItem('Membership Report', `${subDirectory}report/membership`), getsubItem('Membership Report', `${subDirectory}report/membership`),
getsubItem('SelfBooking QR Code', `${subDirectory}report/PublicQrCode`), getsubItem('QR Code Generator',`${subDirectory}setting/report`,
null,
[
getsubItem('Self Booking Qr Code',`${subDirectory}report/PublicQrCode`),
getsubItem('Menu Qr Code', `${subDirectory}report/MenuQRCode`),
]
),
DineinData && dinePreference DineinData && dinePreference
? getsubItem('Table Mapping', `${subDirectory}setting/TableMapping`) ? getsubItem('Table Mapping', `${subDirectory}setting/TableMapping`)
: '', : '',
@ -1319,12 +1325,13 @@ const AppPage = () => {
]; ];
const kotMenu = const kotMenu =
DineinData && dinePreference // DineinData && dinePreference
? [ // ?
getsubItem('KOT', `${subDirectory}kitchen/kot`), [
getsubItem('KOT Display', `${subDirectory}kitchen/kot-display`), getsubItem('Kot', `${subDirectory}kitchen/kot`),
getsubItem('Kot Display', `${subDirectory}kitchen/kot-display`),
] ]
: []; // : [];
const suportMenu = [ const suportMenu = [
!iswarehouse && !iswarehouse &&
@ -1557,7 +1564,7 @@ const AppPage = () => {
), ),
getItem( getItem(
'HOME', 'HOME',
`${subDirectory}`, `${subDirectory}app-page/home`,
<BiHomeSmile className="iconsize" /> <BiHomeSmile className="iconsize" />
), ),
getItem( getItem(
@ -1607,7 +1614,7 @@ const AppPage = () => {
), ),
getItem( getItem(
'HOME', 'HOME',
`${subDirectory}`, `${subDirectory}app-page/home`,
<BiHomeSmile className="iconsize" /> <BiHomeSmile className="iconsize" />
), ),
getItem( getItem(
@ -1643,7 +1650,7 @@ const AppPage = () => {
getItem( getItem(
'Dashboard', 'Dashboard',
`${subDirectory}`, `${subDirectory}app-page/home`,
<MdInsertChartOutlined className="iconsize" /> <MdInsertChartOutlined className="iconsize" />
), ),
getItem('Master', `${subDirectory}master`, <MdDisplaySettings />, [ getItem('Master', `${subDirectory}master`, <MdDisplaySettings />, [
@ -1927,10 +1934,10 @@ const AppPage = () => {
null, null,
[ [
getsubItem( getsubItem(
'Self Booking QR Code', 'Self Booking Qr Code',
`${subDirectory}report/PublicQrCode` `${subDirectory}report/PublicQrCode`
), ),
getsubItem('Menu QR code', `${subDirectory}report/MenuQRCode`), getsubItem('Menu Qr code', `${subDirectory}report/MenuQRCode`),
] ]
), ),
DineinData && dinePreference DineinData && dinePreference
@ -2117,7 +2124,7 @@ const AppPage = () => {
getItem( getItem(
'Dashboard', 'Dashboard',
`${subDirectory}`, `${subDirectory}app-page/home`,
<MdInsertChartOutlined className="iconsize" /> <MdInsertChartOutlined className="iconsize" />
), ),
SadminUserSettingMenu?.length > 0 && SadminUserSettingMenu?.length > 0 &&
@ -2153,7 +2160,7 @@ const AppPage = () => {
// KOT // KOT
sAdminUserFilteredKOTMenu?.length > 0 && sAdminUserFilteredKOTMenu?.length > 0 &&
getItem( getItem(
'KOT', 'Kot',
`${subDirectory}kitchen`, `${subDirectory}kitchen`,
<MdOutlineRestaurantMenu className="iconsize" />, <MdOutlineRestaurantMenu className="iconsize" />,
sAdminUserFilteredKOTMenu sAdminUserFilteredKOTMenu
@ -2203,7 +2210,6 @@ const AppPage = () => {
getsubItem('KOT Display', `${subDirectory}kitchen/kot-display`), getsubItem('KOT Display', `${subDirectory}kitchen/kot-display`),
] ]
: []; : [];
console.log(kotMenu, 'kotMenu');
items.push( items.push(
getItem( getItem(
'MY APPS', 'MY APPS',
@ -2212,7 +2218,7 @@ const AppPage = () => {
), ),
getItem( getItem(
'Dashboard', 'Dashboard',
`${subDirectory}`, `${subDirectory}app-page/home`,
<MdInsertChartOutlined className="iconsize" /> <MdInsertChartOutlined className="iconsize" />
), ),
getItem('Master', `${subDirectory}master`, <MdDisplaySettings />, [ getItem('Master', `${subDirectory}master`, <MdDisplaySettings />, [
@ -2523,10 +2529,10 @@ const AppPage = () => {
// item?.FeatureAddonName?.toLowerCase() === 'kiosk sales' // item?.FeatureAddonName?.toLowerCase() === 'kiosk sales'
// ) && // ) &&
getsubItem( getsubItem(
'Self Booking QR Code', 'Self Booking Qr Code',
`${subDirectory}report/PublicQrCode` `${subDirectory}report/PublicQrCode`
), ),
getsubItem('Menu QR code', `${subDirectory}report/MenuQRCode`), getsubItem('Menu Qr code', `${subDirectory}report/MenuQRCode`),
] ]
), ),
DineinData && dinePreference DineinData && dinePreference
@ -2703,7 +2709,7 @@ const AppPage = () => {
), ),
getItem( getItem(
'Dashboard', 'Dashboard',
`${subDirectory}`, `${subDirectory}app-page/home`,
<MdInsertChartOutlined className="iconsize" /> <MdInsertChartOutlined className="iconsize" />
), ),
@ -2741,7 +2747,7 @@ const AppPage = () => {
// EmpfilterReportMenu?.length > 0 && // EmpfilterReportMenu?.length > 0 &&
!iswarehouse && !iswarehouse &&
getItem( getItem(
'KOT', 'Kot',
`${subDirectory}kitchen`, `${subDirectory}kitchen`,
<MdOutlineRestaurantMenu className="iconsize" />, <MdOutlineRestaurantMenu className="iconsize" />,
empFilteredKOTMenu empFilteredKOTMenu
@ -2787,7 +2793,7 @@ const AppPage = () => {
// Retail Menu Flow Final END // Retail Menu Flow Final END
// *************************** */ // *************************** */
const isCurrentPath = location.pathname === `${subDirectory}`; const isCurrentPath = location.pathname === `${subDirectory}app-page/home`;
console.log(items, 'itemsitems'); console.log(items, 'itemsitems');
return ( return (
<div className="appPage"> <div className="appPage">

View File

@ -25,9 +25,11 @@ import {
changeSelectedBranchId, changeSelectedBranchId,
GenerateLogout, GenerateLogout,
} from '../Features/BrachLogin/BranchLogin'; } from '../Features/BrachLogin/BranchLogin';
import { useNavigate } from 'react-router-dom';
const Logout = () => { const Logout = () => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const navigate = useNavigate();
const commonUrl = import.meta.env.ENV_COMMON_BASE_URL; const commonUrl = import.meta.env.ENV_COMMON_BASE_URL;
const logoutFunc = async () => { const logoutFunc = async () => {
await sessionStore('Mode', 'Logout'); await sessionStore('Mode', 'Logout');
@ -38,6 +40,7 @@ const Logout = () => {
clearSession(); clearSession();
dispatch(changeSelectedBranchId()); dispatch(changeSelectedBranchId());
window.location.replace(commonUrl); window.location.replace(commonUrl);
// navigate(commonUrl, { replace: true }); // Use navigate for better SPA experience
} }
}; };
useEffect(() => { useEffect(() => {

View File

@ -39,7 +39,7 @@ function RedirectApps() {
}; };
const queryParams = new URLSearchParams(param).toString(); const queryParams = new URLSearchParams(param).toString();
window.location.replace( window.location.replace(
`${commonUrl}/home/landing-page/home?${queryParams}` `${commonUrl}/landing-page/home?${queryParams}`
); );
}, []); }, []);

View File

@ -11,7 +11,7 @@ import {
getCommonAppPreference, getCommonAppPreference,
changeWarehouse, changeWarehouse,
} from './Features/BrachLogin/BranchLogin.js'; } from './Features/BrachLogin/BranchLogin.js';
import { clearSession, getSession, sessionStore } from './Services/Others'; import { clearSession, getSession } from './Services/Others';
import { import {
FeatureAddon, FeatureAddon,
GlobalFeatAddOnData, GlobalFeatAddOnData,
@ -43,18 +43,6 @@ const ProtectedRoutes = ({ routesConfig }) => {
const [accessCheckComplete, setAccessCheckComplete] = useState(false); const [accessCheckComplete, setAccessCheckComplete] = useState(false);
const FeatureAddonData = useSelector(GlobalFeatAddOnData); const FeatureAddonData = useSelector(GlobalFeatAddOnData);
useTemplate(CompId, BranchId, AppId); useTemplate(CompId, BranchId, AppId);
sessionStore('AppId', 6);
sessionStore('BranchId', 556);
sessionStore('AppName', 'Bakery');
sessionStore('CompId', 462);
sessionStore('MobileNo', '6382594417');
sessionStore('UserType', 'Admin');
sessionStore('UserId', 1884);
sessionStore('userName', 'Karthiga');
sessionStore(
'auth',
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiNjM4MjU5NDQxNyIsIlBhc3N3b3JkIjoiWkB6NDEwNDg0IiwiYXVkIjpbImh0dHBzOi8vYXBpLnBvem8uZGV2L3Bvem8tcmV0YWlsLWFwaSIsImh0dHBzOi8vYXBpLnBvem8uZGV2L3Bvem8tY29tbW9uLWFwaSIsImh0dHBzOi8vYXBpLnBvem8uZGV2L3Bvem8tc21zLWVtYWlsLXRlbXBsYXRlLWFwaSIsImh0dHBzOi8vYXBpLnBvem8uZGV2L3Bvem8tY29tbW9uLWFwaSJdLCJleHAiOjE3NzUxNTgwNTIsImlzcyI6Imh0dHBzOi8vYXBpLnBvem8uZGV2L0p3dFRva2VuIn0.xPuA6vnS7UdDWAnwMLEPhV0UcqPCwtb7tllpMYjOb-A'
);
useEffect(() => { useEffect(() => {
getApplicationPreference(); getApplicationPreference();
}, []); }, []);
@ -280,221 +268,221 @@ const ProtectedRoutes = ({ routesConfig }) => {
).unwrap(); ).unwrap();
if (response?.data?.statusCode === 1) { if (response?.data?.statusCode === 1) {
if (response?.data?.data?.length == 1) { if (response?.data?.data?.length == 1) {
navigate(`${subDirectory}`); navigate(`${subDirectory}app-page/home`);
} else { } else {
navigate(`${subDirectory}app-page/branch-login`); navigate(`${subDirectory}app-page/branch-login`);
} }
} }
}; };
// useEffect(() => { useEffect(() => {
// const performAccessChecks = async () => { const performAccessChecks = async () => {
// if (!hasRedirected) { if (!hasRedirected) {
// let featureAddon; let featureAddon;
// let featureAddonData; let featureAddonData;
// if (UserType !== 'Super Admin' && UserType !== 'Super Admin User') { if (UserType !== 'Super Admin' && UserType !== 'Super Admin User') {
// if (FeatureAddonData?.FeatureDtls?.length > 0) { if (FeatureAddonData?.FeatureDtls?.length > 0) {
// featureAddonData = FeatureAddonData?.FeatureDtls; featureAddonData = FeatureAddonData?.FeatureDtls;
// } else { } else {
// featureAddon = await dispatch( featureAddon = await dispatch(
// FeatureAddon({ AppId: AppId, UserId: UserId }) FeatureAddon({ AppId: AppId, UserId: UserId })
// ).unwrap(); ).unwrap();
// if (featureAddon?.data?.statusCode === 1) { if (featureAddon?.data?.statusCode === 1) {
// featureAddonData = featureAddonData =
// featureAddon?.data?.data?.[0]?.FeatAddonHdr?.[0]?.FeatureDtls; featureAddon?.data?.data?.[0]?.FeatAddonHdr?.[0]?.FeatureDtls;
// } else { } else {
// featureAddonData = []; featureAddonData = [];
// } }
// } }
// } }
// const currentPath = location.pathname.replace(/\/$/, ''); // Remove trailing slash const currentPath = location.pathname.replace(/\/$/, ''); // Remove trailing slash
// let shouldNavigate = false; let shouldNavigate = false;
// // Find the current route in routesConfig based on currentPath // Find the current route in routesConfig based on currentPath
// const currentRoute = routesConfig?.find((route) => { const currentRoute = routesConfig?.find((route) => {
// if (route.path === currentPath) return true; if (route.path === currentPath) return true;
// if (route.children) { if (route.children) {
// return route.children.some((child) => { return route.children.some((child) => {
// const childPath = `${route.path}/${child.path}`; const childPath = `${route.path}/${child.path}`;
// return childPath === currentPath; return childPath === currentPath;
// }); });
// } }
// return false; return false;
// }); });
// if (!currentRoute) { if (!currentRoute) {
// // alert("Unauthorized action detected. You have been logged out.") // alert("Unauthorized action detected. You have been logged out.")
// Logout(); Logout();
// setHasRedirected(true); setHasRedirected(true);
// return; return;
// } }
// const empAccessData = getEmpAccessFromChildren( const empAccessData = getEmpAccessFromChildren(
// currentRoute, currentRoute,
// currentPath currentPath
// ); );
// const accessData = getEmpAccessDataFromChildren( const accessData = getEmpAccessDataFromChildren(
// currentRoute, currentRoute,
// currentPath currentPath
// ); );
// const checkPreferenceAccessData = ['Dine In', 'KOT', 'Estimate']; const checkPreferenceAccessData = ['Dine In', 'KOT', 'Estimate'];
// const checkPlanAccessData = [ const checkPlanAccessData = [
// 'Product Catalogue', 'Product Catalogue',
// 'Sales Setup', 'Sales Setup',
// 'Print Setup', 'Print Setup',
// 'Kiosk Setup', 'Kiosk Setup',
// 'Kiosk Sales', 'Kiosk Sales',
// ]; ];
// // Cmd it start // Cmd it start
// // if (!UserId && empAccessData != 'Public') { if (!UserId && empAccessData != 'Public') {
// // if (!UserId && (empAccessData === "Kiosk Sales" || empAccessData === "View Bill")) { if (!UserId && (empAccessData === "Kiosk Sales" || empAccessData === "View Bill")) {
// // // Allow KioskBookingPage to load and set session values // Allow KioskBookingPage to load and set session values
// // setAccessCheckComplete(true); setAccessCheckComplete(true);
// // return; return;
// // }else{ }else{
// // console.log("UserId is undefined, logging out..."); console.log("UserId is undefined, logging out...");
// // // alert("User invalid. Redirecting to login...") // alert("User invalid. Redirecting to login...")
// // sessionStorage.clear(); sessionStorage.clear();
// // window.location.replace(`${commonUrl}`); window.location.replace(`${commonUrl}`);
// // setHasRedirected(true); setHasRedirected(true);
// // return; return;
// // } }
// // } }
// // Cmd it End // Cmd it End
// const userAccessChecks = { const userAccessChecks = {
// 'Super Admin': () => { 'Super Admin': () => {
// let empPreferenceCheck = true; let empPreferenceCheck = true;
// if (checkPreferenceAccessData.includes(empAccessData)) { if (checkPreferenceAccessData.includes(empAccessData)) {
// empPreferenceCheck = checkAccess(empAccessData); empPreferenceCheck = checkAccess(empAccessData);
// } else { } else {
// empPreferenceCheck = true; empPreferenceCheck = true;
// } }
// return !empPreferenceCheck; return !empPreferenceCheck;
// }, },
// 'Super Admin User': async () => { 'Super Admin User': async () => {
// const SAdminuserPin = await dispatch( const SAdminuserPin = await dispatch(
// checkSession({ UserId, sessionId }) checkSession({ UserId, sessionId })
// ).unwrap(); ).unwrap();
// if ( if (
// (SAdminuserPin?.data?.statusCode === 1 && (SAdminuserPin?.data?.statusCode === 1 &&
// SAdminuserPin?.data?.data?.filter( SAdminuserPin?.data?.data?.filter(
// (item) => (item) =>
// item?.AppId == AppId && item?.AppId == AppId &&
// item?.CompId == CompId && item?.CompId == CompId &&
// item?.BranchId == BranchId item?.BranchId == BranchId
// )?.[0]?.Status === 'L') || )?.[0]?.Status === 'L') ||
// BranchId === null || BranchId === null ||
// BranchId === '' || BranchId === '' ||
// BranchId === undefined BranchId === undefined
// ) { ) {
// if (sessionStorage.getItem('BranchId') !== null) { if (sessionStorage.getItem('BranchId') !== null) {
// clearSession('BranchId'); clearSession('BranchId');
// } }
// fetchBranchData(); fetchBranchData();
// } else { } else {
// if (empAccessData) { if (empAccessData) {
// const superAdminUserAccessCheck = const superAdminUserAccessCheck =
// await checkSuperAdminUserAccess(empAccessData, currentPath); await checkSuperAdminUserAccess(empAccessData, currentPath);
// let empPreferenceCheck = true; let empPreferenceCheck = true;
// if (checkPreferenceAccessData.includes(empAccessData)) { if (checkPreferenceAccessData.includes(empAccessData)) {
// empPreferenceCheck = checkAccess(empAccessData); empPreferenceCheck = checkAccess(empAccessData);
// } else { } else {
// empPreferenceCheck = true; empPreferenceCheck = true;
// } }
// return !superAdminUserAccessCheck || !empPreferenceCheck; return !superAdminUserAccessCheck || !empPreferenceCheck;
// } else { } else {
// return false; return false;
// } }
// } }
// }, },
// Admin: () => { Admin: () => {
// if (accessData === 'Super Admin') { if (accessData === 'Super Admin') {
// return true; return true;
// } else { } else {
// let empPreferenceCheck = true; let empPreferenceCheck = true;
// let empPlanAccessCheck = true; let empPlanAccessCheck = true;
// if (checkPreferenceAccessData.includes(empAccessData)) { if (checkPreferenceAccessData.includes(empAccessData)) {
// empPreferenceCheck = checkAccess(empAccessData); empPreferenceCheck = checkAccess(empAccessData);
// } else { } else {
// empPreferenceCheck = true; empPreferenceCheck = true;
// } }
// if (checkPlanAccessData.includes(empAccessData)) { if (checkPlanAccessData.includes(empAccessData)) {
// empPlanAccessCheck = checkPlanAccess( empPlanAccessCheck = checkPlanAccess(
// empAccessData, empAccessData,
// featureAddonData featureAddonData
// ); );
// } else { } else {
// empPlanAccessCheck = true; empPlanAccessCheck = true;
// } }
// return !empPreferenceCheck || !empPlanAccessCheck; return !empPreferenceCheck || !empPlanAccessCheck;
// } }
// }, },
// Employee: async () => { Employee: async () => {
// if (empAccessData && accessData !== 'Super Admin') { if (empAccessData && accessData !== 'Super Admin') {
// const empAccessCheck = await checkEmpAccess( const empAccessCheck = await checkEmpAccess(
// empAccessData, empAccessData,
// currentPath currentPath
// ); );
// let empPreferenceCheck = true; let empPreferenceCheck = true;
// let empPlanAccessCheck = true; let empPlanAccessCheck = true;
// if (checkPreferenceAccessData.includes(empAccessData)) { if (checkPreferenceAccessData.includes(empAccessData)) {
// empPreferenceCheck = checkAccess(empAccessData); empPreferenceCheck = checkAccess(empAccessData);
// } else { } else {
// empPreferenceCheck = true; empPreferenceCheck = true;
// } }
// if (checkPlanAccessData.includes(empAccessData)) { if (checkPlanAccessData.includes(empAccessData)) {
// empPlanAccessCheck = checkPlanAccess( empPlanAccessCheck = checkPlanAccess(
// empAccessData, empAccessData,
// featureAddonData featureAddonData
// ); );
// } else { } else {
// empPlanAccessCheck = true; empPlanAccessCheck = true;
// } }
// if (location.pathname === '/app-page/relieve-request') { if (location.pathname === '/app-page/relieve-request') {
// return false; return false;
// } }
// return ( return (
// !empAccessCheck || !empPreferenceCheck || !empPlanAccessCheck !empAccessCheck || !empPreferenceCheck || !empPlanAccessCheck
// ); );
// } else { } else {
// if (accessData === 'Super Admin') { if (accessData === 'Super Admin') {
// return true; return true;
// } else { } else {
// return false; return false;
// } }
// } }
// }, },
// }; };
// if (userAccessChecks[UserType]) { if (userAccessChecks[UserType]) {
// shouldNavigate = await userAccessChecks[UserType](); shouldNavigate = await userAccessChecks[UserType]();
// } else { } else {
// shouldNavigate = true; shouldNavigate = true;
// } }
// console.log('shouldNavigate', shouldNavigate); console.log('shouldNavigate', shouldNavigate);
// if (shouldNavigate) { if (shouldNavigate) {
// // alert("Unauthorized action detected. You have been logged out.") // alert("Unauthorized action detected. You have been logged out.")
// Logout(); Logout();
// setHasRedirected(true); setHasRedirected(true);
// } else { } else {
// console.log('Access granted for current route.'); console.log('Access granted for current route.');
// } }
// setAccessCheckComplete(true); setAccessCheckComplete(true);
// } }
// }; };
// performAccessChecks(); performAccessChecks();
// }, [UserType, routesConfig, navigate, hasRedirected, location.pathname]); }, [UserType, routesConfig, navigate, hasRedirected, location.pathname]);
const Logout = async () => { const Logout = async () => {
const status = 'N'; // replace with your actual status const status = 'N'; // replace with your actual status
@ -542,7 +530,7 @@ const ProtectedRoutes = ({ routesConfig }) => {
return ( return (
<Suspense fallback={<div></div>}> <Suspense fallback={<div></div>}>
<Routes>{ renderRoutes(routesConfig)}</Routes> <Routes>{accessCheckComplete && renderRoutes(routesConfig)}</Routes>
</Suspense> </Suspense>
); );
}; };

View File

@ -149,12 +149,12 @@
// } // }
import React, { useRef, useState, useEffect } from 'react'; import React, { useRef, useState, useEffect } from 'react';
import { BarcodeScanner } from '@capacitor-mlkit/barcode-scanning';
import { BsUpcScan } from 'react-icons/bs'; import { BsUpcScan } from 'react-icons/bs';
import { Capacitor } from '@capacitor/core'; import { Capacitor } from '@capacitor/core';
import { DefaultModal } from '../Components/Modal/DefaultModal'; import { DefaultModal } from '../Components/Modal/DefaultModal';
import QrScanner from 'qr-scanner/qr-scanner.min.js'; import QrScanner from 'qr-scanner/qr-scanner.min.js';
import { BrowserMultiFormatReader, BarcodeFormat } from '@zxing/library'; import { BrowserMultiFormatReader, BarcodeFormat } from '@zxing/library';
import { getBarcode } from './CapacitorService';
QrScanner.WORKER_PATH = new URL( QrScanner.WORKER_PATH = new URL(
'qr-scanner/qr-scanner-worker.min.js', 'qr-scanner/qr-scanner-worker.min.js',
@ -179,6 +179,15 @@ export default function BarCodeScan({ onScan }) {
if (isMobileApp) { if (isMobileApp) {
try { try {
const barcodeModule = await getBarcode();
// If running in browser
if (!barcodeModule) {
setModalOpen(true);
return;
}
const { BarcodeScanner } = barcodeModule;
const perm = await BarcodeScanner.requestPermissions(); const perm = await BarcodeScanner.requestPermissions();
if (perm.camera !== 'granted') { if (perm.camera !== 'granted') {
alert('Camera permission not granted'); alert('Camera permission not granted');

View File

@ -0,0 +1,31 @@
import { Capacitor } from "@capacitor/core";
import { App } from "@capacitor/app";
export const isCapacitor = () => Capacitor.isNativePlatform();
// export const getApp = async () => {
// if (!Capacitor.isNativePlatform()) return null;
// const app = await import("@capacitor/app");
// return app;
// };
export const getBarcode = async () => {
if (!Capacitor.isNativePlatform()) return null;
const barcode = await import("@capacitor-mlkit/barcode-scanning");
return barcode;
};
// Back button listener
export const addBackButtonListener = async (callback) => {
// const App = await getApp();
if (!App) return null;
const listener = await App.addListener("backButton", callback);
return listener;
};
// Minimize app
export const minimizeApp = async () => {
// const App = await getApp();
if (!App) return;
await App.minimizeApp();
};

View File

@ -61,7 +61,7 @@ body {
p { p {
font-family: VAR(--PARA_FONT_FAMILY); font-family: VAR(--PARA_FONT_FAMILY);
} }
button { button {
font-family: var(--BUTTON_FONT_FAMILY); font-family: var(--BUTTON_FONT_FAMILY);
@ -568,9 +568,7 @@ a {
margin: 34px; margin: 34px;
} }
p {
margin-bottom: 0;
}
/* ============================================== /* ==============================================
GLOBAL MARGIN CONTROL - OLD ANDROID DEVICE GLOBAL MARGIN CONTROL - OLD ANDROID DEVICE
@ -591,13 +589,86 @@ p {
--ANDROID_MARGIN-LOCK: 1px 0.4px !important; --ANDROID_MARGIN-LOCK: 1px 0.4px !important;
} }
/* Lock ALL margins for old Android - Full Control */ /* Lock ALL margins for old Android - Full Control - EXCEPT Radio inputs */
.old-android-webview *, .old-android-webview *,
.old-android-webview *:before, .old-android-webview *:before,
.old-android-webview *:after { .old-android-webview *:after {
margin: var(--ANDROID_MARGIN-LOCK, inherit) !important; margin: var(--ANDROID_MARGIN-LOCK, inherit) !important;
} }
/* FIXED: Radio button dot alignment on old Android */
.old-android-webview .ant-radio-inner,
.ant-radio-inner {
position: relative !important;
display: inline-flex !important;
align-items: center !important;
justify-content: center !important;
margin: 0 !important;
}
.old-android-webview .ant-radio-inner::after,
.ant-radio-inner::after {
position: absolute !important;
top: 50% !important;
left: 50% !important;
transform: translate(-50%, -50%) !important;
margin: 0 !important;
width: 6px !important;
height: 6px !important;
border-radius: 50% !important;
}
/* Ensure radio wrapper is not interfering */
.old-android-webview .ant-radio-wrapper,
.ant-radio-wrapper {
display: inline-flex !important;
align-items: center !important;
margin: 0 8px 0 0 !important;
vertical-align: middle !important;
}
/* ============================================
AGGRESSIVE FIX: Global No Scrollbar on Old Android
Suppress ALL unwanted scrollbars in userPageContent & master areas
=========================================== */
.old-android-webview * {
scrollbar-width: none !important;
-ms-overflow-style: none !important;
}
.old-android-webview *::-webkit-scrollbar {
display: none !important;
width: 0 !important;
height: 0 !important;
}
/*
.old-android-webview .userPageContent,
.old-android-webview [class*="userPage"],
.old-android-webview [class*="user-page"],
.old-android-webview [class*="PageContent"],
.old-android-webview [class*="page-content"],
.old-android-webview .master-content,
.old-android-webview main,
.old-android-webview body > div {
overflow: hidden !important;
position: relative !important;
overscroll-behavior: none !important;
height: 100vh !important;
max-height: 100vh !important;
} */
.old-android-webview html,
.old-android-webview body {
overflow: hidden !important;
height: 100vh !important;
max-height: 100vh !important;
position: fixed !important;
width: 100% !important;
top: -4px !important;
left: -2px;
}
/* Per-element margin classes - Use these everywhere */ /* Per-element margin classes - Use these everywhere */
.margin-xxs { margin: var(--GLOBAL_MARGIN-XXS) !important; } .margin-xxs { margin: var(--GLOBAL_MARGIN-XXS) !important; }
.margin-xs { margin: var(--GLOBAL_MARGIN-XS) !important; } .margin-xs { margin: var(--GLOBAL_MARGIN-XS) !important; }
@ -622,3 +693,28 @@ p {
margin: var(--ANDROID_MARGIN-LOCK, 0) !important; margin: var(--ANDROID_MARGIN-LOCK, 0) !important;
} }
.old-android-webview .ProductMasterListSwitchBTN > div{
/* padding:0 1rem !important; */
margin:0 0.5rem !important;
}
.old-android-webview .formNameCustom, .firstVariantVariant{
padding:0 1rem !important;
}
.old-android-webview .offer-schedule-tabs
.days-section {
margin:3rem 0 !important;
}
.old-android-webview .formAddNew
.formSearch{
margin:0 1rem !important;
}

View File

@ -1,4 +1,3 @@
import 'antd/dist/reset.css';
import ReactDOM from 'react-dom/client'; import ReactDOM from 'react-dom/client';
import { Provider } from 'react-redux'; import { Provider } from 'react-redux';
import { BrowserRouter } from 'react-router-dom'; import { BrowserRouter } from 'react-router-dom';
@ -24,6 +23,11 @@ import { isOldAndroidWebView } from './utils/isOldAndroidWebView.js';
import './index.css'; import './index.css';
import "../src/Components/Forms/main.scss" import "../src/Components/Forms/main.scss"
// src\Components\Forms\main.scss // src\Components\Forms\main.scss
// OLD ANDROID ONLY: antd reset CSS dynamic import
if (isOldAndroidWebView) {
import('antd/dist/reset.css');
}
const queryClient = new QueryClient(); const queryClient = new QueryClient();
/* ------------------------------------------------------- /* -------------------------------------------------------

View File

@ -6,37 +6,11 @@ export default defineConfig(({ mode }) => {
const isProd = mode === "production"; const isProd = mode === "production";
return { return {
oxc: {
target: 'es2015'
},
plugins: [
react(),
legacy({
targets: [
"defaults",
"Android >= 5",
"Chrome >= 60"
],
}),
{
name: 'downlevel-dev',
enforce: 'post',
async transform(code, id) {
if (mode === 'development' && /\.(mjs|js|ts|jsx|tsx)(?:[?#]|$)/.test(id)) {
try {
const res = await esbuild.transform(code, { target: 'chrome64', loader: 'jsx' });
return res.code;
} catch (e) {
return code;
}
}
}
}
],
base: isProd ? "/" : "/", //for capcitor base: isProd ? "/" : "/",
plugins: [react()],
base: isProd ? "/apps/retail/" : "/", //for capcitor base: isProd ? "/" : "/",
envDir: "src", envDir: "src",
envPrefix: "ENV_", envPrefix: "ENV_",
@ -46,7 +20,12 @@ export default defineConfig(({ mode }) => {
}, },
build: { build: {
target: "chrome83",
chunkSizeWarningLimit: 1000,
minify: "esbuild", minify: "esbuild",
rollupOptions: {
external: ['/capacitor.js', '/cordova.js', '/native-bridge.js']
},
esbuild: { esbuild: {
drop: isProd ? ["console", "debugger"] : [], drop: isProd ? ["console", "debugger"] : [],
}, },