Retail capacitorplugin changes
This commit is contained in:
parent
ddeed6d14a
commit
44ccf80cf7
|
|
@ -93,7 +93,7 @@
|
|||
);
|
||||
}
|
||||
</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>
|
||||
(function () {
|
||||
|
|
@ -141,7 +141,7 @@
|
|||
}
|
||||
}, 2000);
|
||||
})();
|
||||
</script>
|
||||
</script> -->
|
||||
|
||||
<style>
|
||||
/* ============================================
|
||||
|
|
|
|||
53
src/App.jsx
53
src/App.jsx
|
|
@ -9,13 +9,14 @@ import { isMobile, isIOS } from 'react-device-detect';
|
|||
import { routesConfig } from './routesConfig';
|
||||
import { GlobalItemCard } from './Features/BookingScreen/BookingData/BookingData.js';
|
||||
import { clearSession, getSession, sessionStore } from './Services/Others.js';
|
||||
|
||||
const KisokSelBooking = lazy(
|
||||
() => import('./Pages/SelfBooking/KisokSelBooking')
|
||||
);
|
||||
const IndividualBooking = lazy(
|
||||
() => import('./Pages/SelfBooking/IndividualBooking')
|
||||
);
|
||||
import KisokSelBooking from './Pages/SelfBooking/KisokSelBooking';
|
||||
import IndividualBooking from './Pages/SelfBooking/IndividualBooking';
|
||||
// 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;
|
||||
|
|
@ -27,9 +28,9 @@ import useSessionManager from './useSessionManager.js';
|
|||
import ExtendSubscriptionModal from './Pages/ExtentedModal/ExtendSubscriptionModal.jsx';
|
||||
import devtools from 'devtools-detect';
|
||||
import { Capacitor } from '@capacitor/core';
|
||||
import { addBackButtonListener, isCapacitor, minimizeApp } from './Services/CapacitorService.js';
|
||||
|
||||
// const isCapacitor = () => !!window.Capacitor?.isNativePlatform?.();
|
||||
const isCapacitor = () => Capacitor.isNativePlatform();
|
||||
// ✅ Define your home/exit pages here
|
||||
const HOME_PAGES = [
|
||||
'/app-page/home', // android minimize
|
||||
|
|
@ -55,7 +56,6 @@ const AppRoutes = () => {
|
|||
const [devToolsOpen, setDevToolsOpen] = useState(false);
|
||||
// ✅ Flag to prevent stack push when back button navigates
|
||||
const isBackNav = useRef(false);
|
||||
console.log(isCapacitor(), 'Is Capacitor');
|
||||
// ✅ Build navigation stack
|
||||
useEffect(() => {
|
||||
// Skip pushing to stack when back button caused this navigation
|
||||
|
|
@ -80,7 +80,7 @@ const AppRoutes = () => {
|
|||
sessionStore('navStack', JSON.stringify(stack));
|
||||
console.log('📍 Stack:', stack);
|
||||
}
|
||||
} catch (e) { }
|
||||
} catch (e) {}
|
||||
}, [location.pathname, location.search]);
|
||||
|
||||
// ✅ Web — block browser back button
|
||||
|
|
@ -91,7 +91,7 @@ const AppRoutes = () => {
|
|||
const currentPath = location.pathname;
|
||||
|
||||
const SessionId = getSession('SessionId');
|
||||
console.log('SessionId:', SessionId, 'CurrentPath:', currentPath)
|
||||
console.log('SessionId:', SessionId, 'CurrentPath:', currentPath);
|
||||
// 🟢 If session exists → allow navigation
|
||||
if (SessionId) {
|
||||
console.log('Browser back allowed');
|
||||
|
|
@ -114,11 +114,13 @@ const AppRoutes = () => {
|
|||
|
||||
// ✅ Android — Capacitor back button
|
||||
useEffect(() => {
|
||||
|
||||
if (!isCapacitor()) return;
|
||||
|
||||
const handler = async () => {
|
||||
try {
|
||||
const currentPath = window.location.pathname + window.location.search; // Bug 2 fix
|
||||
|
||||
const currentPath = window.location.pathname + window.location.search;
|
||||
|
||||
const raw = getSession('navStack');
|
||||
let stack = raw ? JSON.parse(raw) : [];
|
||||
|
|
@ -130,36 +132,43 @@ const AppRoutes = () => {
|
|||
if (stack.length > 0) {
|
||||
const previous = stack[stack.length - 1];
|
||||
sessionStore('navStack', JSON.stringify(stack));
|
||||
isBackNav.current = true; // Bug 3 fix — BEFORE navigate
|
||||
isBackNav.current = true;
|
||||
navigate(previous);
|
||||
return;
|
||||
}
|
||||
|
||||
if (HOME_PAGES?.some((p) => currentPath?.includes(p))) {
|
||||
await CapacitorApp.minimizeApp();
|
||||
await minimizeApp();
|
||||
return;
|
||||
}
|
||||
|
||||
if (LOGIN_PAGES?.some((p) => currentPath?.includes(p))) {
|
||||
await CapacitorApp.minimizeApp();
|
||||
await minimizeApp();
|
||||
return;
|
||||
}
|
||||
|
||||
const home = '/app-page/home';
|
||||
isBackNav.current = true; // Bug 3 fix here too
|
||||
isBackNav.current = true;
|
||||
sessionStore('navStack', JSON.stringify([home]));
|
||||
navigate(home);
|
||||
|
||||
} catch (e) {
|
||||
console.error('Back handler error:', e);
|
||||
await CapacitorApp.minimizeApp();
|
||||
console.error("Back handler error:", e);
|
||||
await minimizeApp();
|
||||
}
|
||||
};
|
||||
|
||||
const listenerPromise = CapacitorApp.addListener('backButton', handler); // Bug 1 fix
|
||||
let listener;
|
||||
|
||||
addBackButtonListener(handler).then((l) => {
|
||||
listener = l;
|
||||
});
|
||||
|
||||
return () => {
|
||||
listenerPromise.then(({ remove }) => remove());
|
||||
if (listener) listener.remove();
|
||||
};
|
||||
}, [navigate,location.pathname, location.search]);
|
||||
|
||||
}, [navigate, location.pathname, location.search]);
|
||||
// mohan
|
||||
// useEffect(() => {
|
||||
// if (isMobile || isIOS) {
|
||||
|
|
@ -200,7 +209,7 @@ const AppRoutes = () => {
|
|||
|
||||
// return () => clearInterval(checkDevTools);
|
||||
// }, [devToolsOpen]);
|
||||
|
||||
|
||||
if (extendModel) {
|
||||
return (
|
||||
<ExtendSubscriptionModal
|
||||
|
|
|
|||
|
|
@ -825,7 +825,7 @@ const AppPage = () => {
|
|||
// featureaddDetails?.find(
|
||||
// (item) => item?.FeatureAddonName?.toLowerCase() === 'kiosk sales'
|
||||
// ) &&
|
||||
getsubItem('Self Booking QR Code', `${subDirectory}report/PublicQrCode`),
|
||||
getsubItem('Self Booking Qr Code', `${subDirectory}report/PublicQrCode`),
|
||||
DineinData && dinePreference
|
||||
? getsubItem('Table Mapping', `${subDirectory}setting/TableMapping`)
|
||||
: '',
|
||||
|
|
@ -840,8 +840,8 @@ const AppPage = () => {
|
|||
const superAdminUserKOTMenu =
|
||||
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`),
|
||||
]
|
||||
: [];
|
||||
|
||||
|
|
@ -1301,7 +1301,13 @@ const AppPage = () => {
|
|||
getsubItem('Reprint Details', `${subDirectory}report/reprintreasonreport`),
|
||||
sportsAppPreference &&
|
||||
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
|
||||
? getsubItem('Table Mapping', `${subDirectory}setting/TableMapping`)
|
||||
: '',
|
||||
|
|
@ -1319,12 +1325,13 @@ const AppPage = () => {
|
|||
];
|
||||
|
||||
const kotMenu =
|
||||
DineinData && dinePreference
|
||||
? [
|
||||
getsubItem('KOT', `${subDirectory}kitchen/kot`),
|
||||
getsubItem('KOT Display', `${subDirectory}kitchen/kot-display`),
|
||||
// DineinData && dinePreference
|
||||
// ?
|
||||
[
|
||||
getsubItem('Kot', `${subDirectory}kitchen/kot`),
|
||||
getsubItem('Kot Display', `${subDirectory}kitchen/kot-display`),
|
||||
]
|
||||
: [];
|
||||
// : [];
|
||||
|
||||
const suportMenu = [
|
||||
!iswarehouse &&
|
||||
|
|
@ -1557,7 +1564,7 @@ const AppPage = () => {
|
|||
),
|
||||
getItem(
|
||||
'HOME',
|
||||
`${subDirectory}`,
|
||||
`${subDirectory}app-page/home`,
|
||||
<BiHomeSmile className="iconsize" />
|
||||
),
|
||||
getItem(
|
||||
|
|
@ -1607,7 +1614,7 @@ const AppPage = () => {
|
|||
),
|
||||
getItem(
|
||||
'HOME',
|
||||
`${subDirectory}`,
|
||||
`${subDirectory}app-page/home`,
|
||||
<BiHomeSmile className="iconsize" />
|
||||
),
|
||||
getItem(
|
||||
|
|
@ -1643,7 +1650,7 @@ const AppPage = () => {
|
|||
|
||||
getItem(
|
||||
'Dashboard',
|
||||
`${subDirectory}`,
|
||||
`${subDirectory}app-page/home`,
|
||||
<MdInsertChartOutlined className="iconsize" />
|
||||
),
|
||||
getItem('Master', `${subDirectory}master`, <MdDisplaySettings />, [
|
||||
|
|
@ -1927,10 +1934,10 @@ const AppPage = () => {
|
|||
null,
|
||||
[
|
||||
getsubItem(
|
||||
'Self Booking QR Code',
|
||||
'Self Booking Qr Code',
|
||||
`${subDirectory}report/PublicQrCode`
|
||||
),
|
||||
getsubItem('Menu QR code', `${subDirectory}report/MenuQRCode`),
|
||||
getsubItem('Menu Qr code', `${subDirectory}report/MenuQRCode`),
|
||||
]
|
||||
),
|
||||
DineinData && dinePreference
|
||||
|
|
@ -2117,7 +2124,7 @@ const AppPage = () => {
|
|||
|
||||
getItem(
|
||||
'Dashboard',
|
||||
`${subDirectory}`,
|
||||
`${subDirectory}app-page/home`,
|
||||
<MdInsertChartOutlined className="iconsize" />
|
||||
),
|
||||
SadminUserSettingMenu?.length > 0 &&
|
||||
|
|
@ -2153,7 +2160,7 @@ const AppPage = () => {
|
|||
// KOT
|
||||
sAdminUserFilteredKOTMenu?.length > 0 &&
|
||||
getItem(
|
||||
'KOT',
|
||||
'Kot',
|
||||
`${subDirectory}kitchen`,
|
||||
<MdOutlineRestaurantMenu className="iconsize" />,
|
||||
sAdminUserFilteredKOTMenu
|
||||
|
|
@ -2203,7 +2210,6 @@ const AppPage = () => {
|
|||
getsubItem('KOT Display', `${subDirectory}kitchen/kot-display`),
|
||||
]
|
||||
: [];
|
||||
console.log(kotMenu, 'kotMenu');
|
||||
items.push(
|
||||
getItem(
|
||||
'MY APPS',
|
||||
|
|
@ -2212,7 +2218,7 @@ const AppPage = () => {
|
|||
),
|
||||
getItem(
|
||||
'Dashboard',
|
||||
`${subDirectory}`,
|
||||
`${subDirectory}app-page/home`,
|
||||
<MdInsertChartOutlined className="iconsize" />
|
||||
),
|
||||
getItem('Master', `${subDirectory}master`, <MdDisplaySettings />, [
|
||||
|
|
@ -2523,10 +2529,10 @@ const AppPage = () => {
|
|||
// item?.FeatureAddonName?.toLowerCase() === 'kiosk sales'
|
||||
// ) &&
|
||||
getsubItem(
|
||||
'Self Booking QR Code',
|
||||
'Self Booking Qr Code',
|
||||
`${subDirectory}report/PublicQrCode`
|
||||
),
|
||||
getsubItem('Menu QR code', `${subDirectory}report/MenuQRCode`),
|
||||
getsubItem('Menu Qr code', `${subDirectory}report/MenuQRCode`),
|
||||
]
|
||||
),
|
||||
DineinData && dinePreference
|
||||
|
|
@ -2703,7 +2709,7 @@ const AppPage = () => {
|
|||
),
|
||||
getItem(
|
||||
'Dashboard',
|
||||
`${subDirectory}`,
|
||||
`${subDirectory}app-page/home`,
|
||||
<MdInsertChartOutlined className="iconsize" />
|
||||
),
|
||||
|
||||
|
|
@ -2741,7 +2747,7 @@ const AppPage = () => {
|
|||
// EmpfilterReportMenu?.length > 0 &&
|
||||
!iswarehouse &&
|
||||
getItem(
|
||||
'KOT',
|
||||
'Kot',
|
||||
`${subDirectory}kitchen`,
|
||||
<MdOutlineRestaurantMenu className="iconsize" />,
|
||||
empFilteredKOTMenu
|
||||
|
|
@ -2787,7 +2793,7 @@ const AppPage = () => {
|
|||
// Retail Menu Flow Final END
|
||||
// *************************** */
|
||||
|
||||
const isCurrentPath = location.pathname === `${subDirectory}`;
|
||||
const isCurrentPath = location.pathname === `${subDirectory}app-page/home`;
|
||||
console.log(items, 'itemsitems');
|
||||
return (
|
||||
<div className="appPage">
|
||||
|
|
|
|||
|
|
@ -25,9 +25,11 @@ import {
|
|||
changeSelectedBranchId,
|
||||
GenerateLogout,
|
||||
} from '../Features/BrachLogin/BranchLogin';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
const Logout = () => {
|
||||
const dispatch = useDispatch();
|
||||
const navigate = useNavigate();
|
||||
const commonUrl = import.meta.env.ENV_COMMON_BASE_URL;
|
||||
const logoutFunc = async () => {
|
||||
await sessionStore('Mode', 'Logout');
|
||||
|
|
@ -38,6 +40,7 @@ const Logout = () => {
|
|||
clearSession();
|
||||
dispatch(changeSelectedBranchId());
|
||||
window.location.replace(commonUrl);
|
||||
// navigate(commonUrl, { replace: true }); // Use navigate for better SPA experience
|
||||
}
|
||||
};
|
||||
useEffect(() => {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ function RedirectApps() {
|
|||
};
|
||||
const queryParams = new URLSearchParams(param).toString();
|
||||
window.location.replace(
|
||||
`${commonUrl}/home/landing-page/home?${queryParams}`
|
||||
`${commonUrl}/landing-page/home?${queryParams}`
|
||||
);
|
||||
}, []);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import {
|
|||
getCommonAppPreference,
|
||||
changeWarehouse,
|
||||
} from './Features/BrachLogin/BranchLogin.js';
|
||||
import { clearSession, getSession, sessionStore } from './Services/Others';
|
||||
import { clearSession, getSession } from './Services/Others';
|
||||
import {
|
||||
FeatureAddon,
|
||||
GlobalFeatAddOnData,
|
||||
|
|
@ -43,18 +43,6 @@ const ProtectedRoutes = ({ routesConfig }) => {
|
|||
const [accessCheckComplete, setAccessCheckComplete] = useState(false);
|
||||
const FeatureAddonData = useSelector(GlobalFeatAddOnData);
|
||||
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(() => {
|
||||
getApplicationPreference();
|
||||
}, []);
|
||||
|
|
@ -280,221 +268,221 @@ const ProtectedRoutes = ({ routesConfig }) => {
|
|||
).unwrap();
|
||||
if (response?.data?.statusCode === 1) {
|
||||
if (response?.data?.data?.length == 1) {
|
||||
navigate(`${subDirectory}`);
|
||||
navigate(`${subDirectory}app-page/home`);
|
||||
} else {
|
||||
navigate(`${subDirectory}app-page/branch-login`);
|
||||
}
|
||||
}
|
||||
};
|
||||
// useEffect(() => {
|
||||
// const performAccessChecks = async () => {
|
||||
// if (!hasRedirected) {
|
||||
// let featureAddon;
|
||||
// let featureAddonData;
|
||||
useEffect(() => {
|
||||
const performAccessChecks = async () => {
|
||||
if (!hasRedirected) {
|
||||
let featureAddon;
|
||||
let featureAddonData;
|
||||
|
||||
// if (UserType !== 'Super Admin' && UserType !== 'Super Admin User') {
|
||||
// if (FeatureAddonData?.FeatureDtls?.length > 0) {
|
||||
// featureAddonData = FeatureAddonData?.FeatureDtls;
|
||||
// } else {
|
||||
// featureAddon = await dispatch(
|
||||
// FeatureAddon({ AppId: AppId, UserId: UserId })
|
||||
// ).unwrap();
|
||||
// if (featureAddon?.data?.statusCode === 1) {
|
||||
// featureAddonData =
|
||||
// featureAddon?.data?.data?.[0]?.FeatAddonHdr?.[0]?.FeatureDtls;
|
||||
// } else {
|
||||
// featureAddonData = [];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
if (UserType !== 'Super Admin' && UserType !== 'Super Admin User') {
|
||||
if (FeatureAddonData?.FeatureDtls?.length > 0) {
|
||||
featureAddonData = FeatureAddonData?.FeatureDtls;
|
||||
} else {
|
||||
featureAddon = await dispatch(
|
||||
FeatureAddon({ AppId: AppId, UserId: UserId })
|
||||
).unwrap();
|
||||
if (featureAddon?.data?.statusCode === 1) {
|
||||
featureAddonData =
|
||||
featureAddon?.data?.data?.[0]?.FeatAddonHdr?.[0]?.FeatureDtls;
|
||||
} else {
|
||||
featureAddonData = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// const currentPath = location.pathname.replace(/\/$/, ''); // Remove trailing slash
|
||||
// let shouldNavigate = false;
|
||||
const currentPath = location.pathname.replace(/\/$/, ''); // Remove trailing slash
|
||||
let shouldNavigate = false;
|
||||
|
||||
// // Find the current route in routesConfig based on currentPath
|
||||
// const currentRoute = routesConfig?.find((route) => {
|
||||
// if (route.path === currentPath) return true;
|
||||
// if (route.children) {
|
||||
// return route.children.some((child) => {
|
||||
// const childPath = `${route.path}/${child.path}`;
|
||||
// return childPath === currentPath;
|
||||
// });
|
||||
// }
|
||||
// return false;
|
||||
// });
|
||||
// Find the current route in routesConfig based on currentPath
|
||||
const currentRoute = routesConfig?.find((route) => {
|
||||
if (route.path === currentPath) return true;
|
||||
if (route.children) {
|
||||
return route.children.some((child) => {
|
||||
const childPath = `${route.path}/${child.path}`;
|
||||
return childPath === currentPath;
|
||||
});
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
// if (!currentRoute) {
|
||||
// // alert("Unauthorized action detected. You have been logged out.")
|
||||
// Logout();
|
||||
// setHasRedirected(true);
|
||||
// return;
|
||||
// }
|
||||
if (!currentRoute) {
|
||||
// alert("Unauthorized action detected. You have been logged out.")
|
||||
Logout();
|
||||
setHasRedirected(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// const empAccessData = getEmpAccessFromChildren(
|
||||
// currentRoute,
|
||||
// currentPath
|
||||
// );
|
||||
// const accessData = getEmpAccessDataFromChildren(
|
||||
// currentRoute,
|
||||
// currentPath
|
||||
// );
|
||||
const empAccessData = getEmpAccessFromChildren(
|
||||
currentRoute,
|
||||
currentPath
|
||||
);
|
||||
const accessData = getEmpAccessDataFromChildren(
|
||||
currentRoute,
|
||||
currentPath
|
||||
);
|
||||
|
||||
// const checkPreferenceAccessData = ['Dine In', 'KOT', 'Estimate'];
|
||||
// const checkPlanAccessData = [
|
||||
// 'Product Catalogue',
|
||||
// 'Sales Setup',
|
||||
// 'Print Setup',
|
||||
// 'Kiosk Setup',
|
||||
// 'Kiosk Sales',
|
||||
// ];
|
||||
// // Cmd it start
|
||||
const checkPreferenceAccessData = ['Dine In', 'KOT', 'Estimate'];
|
||||
const checkPlanAccessData = [
|
||||
'Product Catalogue',
|
||||
'Sales Setup',
|
||||
'Print Setup',
|
||||
'Kiosk Setup',
|
||||
'Kiosk Sales',
|
||||
];
|
||||
// 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 = {
|
||||
// 'Super Admin': () => {
|
||||
// let empPreferenceCheck = true;
|
||||
// if (checkPreferenceAccessData.includes(empAccessData)) {
|
||||
// empPreferenceCheck = checkAccess(empAccessData);
|
||||
// } else {
|
||||
// empPreferenceCheck = true;
|
||||
// }
|
||||
// return !empPreferenceCheck;
|
||||
// },
|
||||
// 'Super Admin User': async () => {
|
||||
// const SAdminuserPin = await dispatch(
|
||||
// checkSession({ UserId, sessionId })
|
||||
// ).unwrap();
|
||||
// if (
|
||||
// (SAdminuserPin?.data?.statusCode === 1 &&
|
||||
// SAdminuserPin?.data?.data?.filter(
|
||||
// (item) =>
|
||||
// item?.AppId == AppId &&
|
||||
// item?.CompId == CompId &&
|
||||
// item?.BranchId == BranchId
|
||||
// )?.[0]?.Status === 'L') ||
|
||||
// BranchId === null ||
|
||||
// BranchId === '' ||
|
||||
// BranchId === undefined
|
||||
// ) {
|
||||
// if (sessionStorage.getItem('BranchId') !== null) {
|
||||
// clearSession('BranchId');
|
||||
// }
|
||||
// fetchBranchData();
|
||||
// } else {
|
||||
// if (empAccessData) {
|
||||
// const superAdminUserAccessCheck =
|
||||
// await checkSuperAdminUserAccess(empAccessData, currentPath);
|
||||
// let empPreferenceCheck = true;
|
||||
// if (checkPreferenceAccessData.includes(empAccessData)) {
|
||||
// empPreferenceCheck = checkAccess(empAccessData);
|
||||
// } else {
|
||||
// empPreferenceCheck = true;
|
||||
// }
|
||||
// return !superAdminUserAccessCheck || !empPreferenceCheck;
|
||||
// } else {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// Admin: () => {
|
||||
// if (accessData === 'Super Admin') {
|
||||
// return true;
|
||||
// } else {
|
||||
// let empPreferenceCheck = true;
|
||||
// let empPlanAccessCheck = true;
|
||||
// Cmd it End
|
||||
const userAccessChecks = {
|
||||
'Super Admin': () => {
|
||||
let empPreferenceCheck = true;
|
||||
if (checkPreferenceAccessData.includes(empAccessData)) {
|
||||
empPreferenceCheck = checkAccess(empAccessData);
|
||||
} else {
|
||||
empPreferenceCheck = true;
|
||||
}
|
||||
return !empPreferenceCheck;
|
||||
},
|
||||
'Super Admin User': async () => {
|
||||
const SAdminuserPin = await dispatch(
|
||||
checkSession({ UserId, sessionId })
|
||||
).unwrap();
|
||||
if (
|
||||
(SAdminuserPin?.data?.statusCode === 1 &&
|
||||
SAdminuserPin?.data?.data?.filter(
|
||||
(item) =>
|
||||
item?.AppId == AppId &&
|
||||
item?.CompId == CompId &&
|
||||
item?.BranchId == BranchId
|
||||
)?.[0]?.Status === 'L') ||
|
||||
BranchId === null ||
|
||||
BranchId === '' ||
|
||||
BranchId === undefined
|
||||
) {
|
||||
if (sessionStorage.getItem('BranchId') !== null) {
|
||||
clearSession('BranchId');
|
||||
}
|
||||
fetchBranchData();
|
||||
} else {
|
||||
if (empAccessData) {
|
||||
const superAdminUserAccessCheck =
|
||||
await checkSuperAdminUserAccess(empAccessData, currentPath);
|
||||
let empPreferenceCheck = true;
|
||||
if (checkPreferenceAccessData.includes(empAccessData)) {
|
||||
empPreferenceCheck = checkAccess(empAccessData);
|
||||
} else {
|
||||
empPreferenceCheck = true;
|
||||
}
|
||||
return !superAdminUserAccessCheck || !empPreferenceCheck;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
},
|
||||
Admin: () => {
|
||||
if (accessData === 'Super Admin') {
|
||||
return true;
|
||||
} else {
|
||||
let empPreferenceCheck = true;
|
||||
let empPlanAccessCheck = true;
|
||||
|
||||
// if (checkPreferenceAccessData.includes(empAccessData)) {
|
||||
// empPreferenceCheck = checkAccess(empAccessData);
|
||||
// } else {
|
||||
// empPreferenceCheck = true;
|
||||
// }
|
||||
if (checkPreferenceAccessData.includes(empAccessData)) {
|
||||
empPreferenceCheck = checkAccess(empAccessData);
|
||||
} else {
|
||||
empPreferenceCheck = true;
|
||||
}
|
||||
|
||||
// if (checkPlanAccessData.includes(empAccessData)) {
|
||||
// empPlanAccessCheck = checkPlanAccess(
|
||||
// empAccessData,
|
||||
// featureAddonData
|
||||
// );
|
||||
// } else {
|
||||
// empPlanAccessCheck = true;
|
||||
// }
|
||||
if (checkPlanAccessData.includes(empAccessData)) {
|
||||
empPlanAccessCheck = checkPlanAccess(
|
||||
empAccessData,
|
||||
featureAddonData
|
||||
);
|
||||
} else {
|
||||
empPlanAccessCheck = true;
|
||||
}
|
||||
|
||||
// return !empPreferenceCheck || !empPlanAccessCheck;
|
||||
// }
|
||||
// },
|
||||
// Employee: async () => {
|
||||
// if (empAccessData && accessData !== 'Super Admin') {
|
||||
// const empAccessCheck = await checkEmpAccess(
|
||||
// empAccessData,
|
||||
// currentPath
|
||||
// );
|
||||
// let empPreferenceCheck = true;
|
||||
// let empPlanAccessCheck = true;
|
||||
return !empPreferenceCheck || !empPlanAccessCheck;
|
||||
}
|
||||
},
|
||||
Employee: async () => {
|
||||
if (empAccessData && accessData !== 'Super Admin') {
|
||||
const empAccessCheck = await checkEmpAccess(
|
||||
empAccessData,
|
||||
currentPath
|
||||
);
|
||||
let empPreferenceCheck = true;
|
||||
let empPlanAccessCheck = true;
|
||||
|
||||
// if (checkPreferenceAccessData.includes(empAccessData)) {
|
||||
// empPreferenceCheck = checkAccess(empAccessData);
|
||||
// } else {
|
||||
// empPreferenceCheck = true;
|
||||
// }
|
||||
if (checkPreferenceAccessData.includes(empAccessData)) {
|
||||
empPreferenceCheck = checkAccess(empAccessData);
|
||||
} else {
|
||||
empPreferenceCheck = true;
|
||||
}
|
||||
|
||||
// if (checkPlanAccessData.includes(empAccessData)) {
|
||||
// empPlanAccessCheck = checkPlanAccess(
|
||||
// empAccessData,
|
||||
// featureAddonData
|
||||
// );
|
||||
// } else {
|
||||
// empPlanAccessCheck = true;
|
||||
// }
|
||||
// if (location.pathname === '/app-page/relieve-request') {
|
||||
// return false;
|
||||
// }
|
||||
// return (
|
||||
// !empAccessCheck || !empPreferenceCheck || !empPlanAccessCheck
|
||||
// );
|
||||
// } else {
|
||||
// if (accessData === 'Super Admin') {
|
||||
// return true;
|
||||
// } else {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// };
|
||||
if (checkPlanAccessData.includes(empAccessData)) {
|
||||
empPlanAccessCheck = checkPlanAccess(
|
||||
empAccessData,
|
||||
featureAddonData
|
||||
);
|
||||
} else {
|
||||
empPlanAccessCheck = true;
|
||||
}
|
||||
if (location.pathname === '/app-page/relieve-request') {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
!empAccessCheck || !empPreferenceCheck || !empPlanAccessCheck
|
||||
);
|
||||
} else {
|
||||
if (accessData === 'Super Admin') {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
// if (userAccessChecks[UserType]) {
|
||||
// shouldNavigate = await userAccessChecks[UserType]();
|
||||
// } else {
|
||||
// shouldNavigate = true;
|
||||
// }
|
||||
// console.log('shouldNavigate', shouldNavigate);
|
||||
// if (shouldNavigate) {
|
||||
// // alert("Unauthorized action detected. You have been logged out.")
|
||||
// Logout();
|
||||
// setHasRedirected(true);
|
||||
// } else {
|
||||
// console.log('Access granted for current route.');
|
||||
// }
|
||||
if (userAccessChecks[UserType]) {
|
||||
shouldNavigate = await userAccessChecks[UserType]();
|
||||
} else {
|
||||
shouldNavigate = true;
|
||||
}
|
||||
console.log('shouldNavigate', shouldNavigate);
|
||||
if (shouldNavigate) {
|
||||
// alert("Unauthorized action detected. You have been logged out.")
|
||||
Logout();
|
||||
setHasRedirected(true);
|
||||
} else {
|
||||
console.log('Access granted for current route.');
|
||||
}
|
||||
|
||||
// setAccessCheckComplete(true);
|
||||
// }
|
||||
// };
|
||||
setAccessCheckComplete(true);
|
||||
}
|
||||
};
|
||||
|
||||
// performAccessChecks();
|
||||
// }, [UserType, routesConfig, navigate, hasRedirected, location.pathname]);
|
||||
performAccessChecks();
|
||||
}, [UserType, routesConfig, navigate, hasRedirected, location.pathname]);
|
||||
|
||||
const Logout = async () => {
|
||||
const status = 'N'; // replace with your actual status
|
||||
|
|
@ -542,7 +530,7 @@ const ProtectedRoutes = ({ routesConfig }) => {
|
|||
|
||||
return (
|
||||
<Suspense fallback={<div></div>}>
|
||||
<Routes>{ renderRoutes(routesConfig)}</Routes>
|
||||
<Routes>{accessCheckComplete && renderRoutes(routesConfig)}</Routes>
|
||||
</Suspense>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -149,12 +149,12 @@
|
|||
// }
|
||||
|
||||
import React, { useRef, useState, useEffect } from 'react';
|
||||
import { BarcodeScanner } from '@capacitor-mlkit/barcode-scanning';
|
||||
import { BsUpcScan } from 'react-icons/bs';
|
||||
import { Capacitor } from '@capacitor/core';
|
||||
import { DefaultModal } from '../Components/Modal/DefaultModal';
|
||||
import QrScanner from 'qr-scanner/qr-scanner.min.js';
|
||||
import { BrowserMultiFormatReader, BarcodeFormat } from '@zxing/library';
|
||||
import { getBarcode } from './CapacitorService';
|
||||
|
||||
QrScanner.WORKER_PATH = new URL(
|
||||
'qr-scanner/qr-scanner-worker.min.js',
|
||||
|
|
@ -179,6 +179,15 @@ export default function BarCodeScan({ onScan }) {
|
|||
|
||||
if (isMobileApp) {
|
||||
try {
|
||||
const barcodeModule = await getBarcode();
|
||||
|
||||
// If running in browser
|
||||
if (!barcodeModule) {
|
||||
setModalOpen(true);
|
||||
return;
|
||||
}
|
||||
|
||||
const { BarcodeScanner } = barcodeModule;
|
||||
const perm = await BarcodeScanner.requestPermissions();
|
||||
if (perm.camera !== 'granted') {
|
||||
alert('Camera permission not granted');
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
};
|
||||
106
src/index.css
106
src/index.css
|
|
@ -61,7 +61,7 @@ body {
|
|||
|
||||
p {
|
||||
font-family: VAR(--PARA_FONT_FAMILY);
|
||||
}
|
||||
}
|
||||
|
||||
button {
|
||||
font-family: var(--BUTTON_FONT_FAMILY);
|
||||
|
|
@ -568,9 +568,7 @@ a {
|
|||
margin: 34px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
|
||||
/* ==============================================
|
||||
GLOBAL MARGIN CONTROL - OLD ANDROID DEVICE
|
||||
|
|
@ -591,13 +589,86 @@ p {
|
|||
--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 *:before,
|
||||
.old-android-webview *:after {
|
||||
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 */
|
||||
.margin-xxs { margin: var(--GLOBAL_MARGIN-XXS) !important; }
|
||||
.margin-xs { margin: var(--GLOBAL_MARGIN-XS) !important; }
|
||||
|
|
@ -622,3 +693,28 @@ p {
|
|||
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;
|
||||
|
||||
}
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
import 'antd/dist/reset.css';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import { Provider } from 'react-redux';
|
||||
import { BrowserRouter } from 'react-router-dom';
|
||||
|
|
@ -24,6 +23,11 @@ import { isOldAndroidWebView } from './utils/isOldAndroidWebView.js';
|
|||
import './index.css';
|
||||
import "../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();
|
||||
|
||||
/* -------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -6,37 +6,11 @@ export default defineConfig(({ mode }) => {
|
|||
const isProd = mode === "production";
|
||||
|
||||
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",
|
||||
envPrefix: "ENV_",
|
||||
|
||||
|
|
@ -46,7 +20,12 @@ export default defineConfig(({ mode }) => {
|
|||
},
|
||||
|
||||
build: {
|
||||
target: "chrome83",
|
||||
chunkSizeWarningLimit: 1000,
|
||||
minify: "esbuild",
|
||||
rollupOptions: {
|
||||
external: ['/capacitor.js', '/cordova.js', '/native-bridge.js']
|
||||
},
|
||||
esbuild: {
|
||||
drop: isProd ? ["console", "debugger"] : [],
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue