Fix #317 Reports Intent Print changes
This commit is contained in:
parent
8c80629ca4
commit
5c0f168a37
150
src/App.jsx
150
src/App.jsx
|
|
@ -8,7 +8,7 @@ import SelfBooking from './Pages/SelfBooking/SelfBooking.jsx';
|
||||||
import { isMobile, isIOS } from 'react-device-detect';
|
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 } from './Services/Others.js';
|
import { clearSession, getSession, sessionStore } from './Services/Others.js';
|
||||||
|
|
||||||
const KisokSelBooking = lazy(
|
const KisokSelBooking = lazy(
|
||||||
() => import('./Pages/SelfBooking/KisokSelBooking')
|
() => import('./Pages/SelfBooking/KisokSelBooking')
|
||||||
|
|
@ -27,9 +27,10 @@ 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 { useDevToolsDetection } from './utils/useDevToolsDetection.js';
|
import { useDevToolsDetection } from './utils/useDevToolsDetection.js';
|
||||||
|
import { Capacitor } from '@capacitor/core';
|
||||||
|
|
||||||
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,7 @@ 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
|
||||||
|
|
@ -70,13 +71,14 @@ const AppRoutes = () => {
|
||||||
// Don't track login pages
|
// Don't track login pages
|
||||||
if (LOGIN_PAGES.some((p) => path.includes(p))) return;
|
if (LOGIN_PAGES.some((p) => path.includes(p))) return;
|
||||||
|
|
||||||
const raw = sessionStorage.getItem('navStack');
|
const raw = getSession('navStack');
|
||||||
|
console.log('🎯 Current path:', path);
|
||||||
let stack = raw ? JSON.parse(raw) : [];
|
let stack = raw ? JSON.parse(raw) : [];
|
||||||
|
|
||||||
if (stack.length === 0 || stack[stack.length - 1] !== path) {
|
if (stack.length === 0 || stack[stack.length - 1] !== path) {
|
||||||
stack.push(path);
|
stack.push(path);
|
||||||
if (stack.length > 50) stack = stack.slice(-50);
|
if (stack.length > 50) stack = stack.slice(-50);
|
||||||
sessionStorage.setItem('navStack', JSON.stringify(stack));
|
sessionStore('navStack', JSON.stringify(stack));
|
||||||
console.log('📍 Stack:', stack);
|
console.log('📍 Stack:', stack);
|
||||||
}
|
}
|
||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
|
|
@ -90,7 +92,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)
|
||||||
// 🟢 If session exists → allow navigation
|
// 🟢 If session exists → allow navigation
|
||||||
if (SessionId) {
|
if (SessionId) {
|
||||||
console.log('Browser back allowed');
|
console.log('Browser back allowed');
|
||||||
|
|
@ -112,65 +114,53 @@ const AppRoutes = () => {
|
||||||
}, [location.pathname]);
|
}, [location.pathname]);
|
||||||
|
|
||||||
// ✅ 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 = location.pathname + (location.search || '');
|
const currentPath = window.location.pathname + window.location.search; // Bug 2 fix
|
||||||
console.log('🔙 Back pressed:', currentPath);
|
|
||||||
|
|
||||||
const raw = sessionStorage.getItem('navStack');
|
const raw = getSession('navStack');
|
||||||
let stack = raw ? JSON.parse(raw) : [];
|
let stack = raw ? JSON.parse(raw) : [];
|
||||||
|
|
||||||
// Remove current path from stack if it's at the end
|
while (stack.length && stack[stack.length - 1] === currentPath) {
|
||||||
while (stack.length && stack[stack.length - 1] === currentPath) {
|
stack.pop();
|
||||||
stack.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
// If there are pages in history, go back to previous page
|
|
||||||
if (stack.length > 0) {
|
|
||||||
const previous = stack[stack.length - 1];
|
|
||||||
sessionStorage.setItem('navStack', JSON.stringify(stack));
|
|
||||||
isBackNav.current = true;
|
|
||||||
navigate(previous);
|
|
||||||
console.log('Navigate to previous:', previous);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stack is empty - check where we are
|
|
||||||
// 🏠 Home page → minimize
|
|
||||||
if (HOME_PAGES?.some((p) => currentPath?.includes(p))) {
|
|
||||||
console.log('Home page & empty stack → minimizing app');
|
|
||||||
await CapacitorApp.minimizeApp();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 🚪 Login page → minimize
|
|
||||||
if (LOGIN_PAGES?.some((p) => currentPath?.includes(p))) {
|
|
||||||
console.log('Login page & empty stack → minimizing app');
|
|
||||||
await CapacitorApp.minimizeApp();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Anywhere else with empty stack → go to home
|
|
||||||
const home = '/app-page/home';
|
|
||||||
sessionStorage.setItem('navStack', JSON.stringify([home]));
|
|
||||||
isBackNav.current = true;
|
|
||||||
navigate(home);
|
|
||||||
console.log('Empty stack, navigate to home');
|
|
||||||
} catch (e) {
|
|
||||||
console.error('Back handler error:', e);
|
|
||||||
await CapacitorApp.minimizeApp();
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
const listener = CapacitorApp.addListener('backButton', handler);
|
if (stack.length > 0) {
|
||||||
|
const previous = stack[stack.length - 1];
|
||||||
|
sessionStore('navStack', JSON.stringify(stack));
|
||||||
|
isBackNav.current = true; // Bug 3 fix — BEFORE navigate
|
||||||
|
navigate(previous);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
return () => {
|
if (HOME_PAGES?.some((p) => currentPath?.includes(p))) {
|
||||||
listener.remove();
|
await CapacitorApp.minimizeApp();
|
||||||
};
|
return;
|
||||||
}, [navigate, location.pathname, location.search]);
|
}
|
||||||
|
|
||||||
|
if (LOGIN_PAGES?.some((p) => currentPath?.includes(p))) {
|
||||||
|
await CapacitorApp.minimizeApp();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const home = '/app-page/home';
|
||||||
|
isBackNav.current = true; // Bug 3 fix here too
|
||||||
|
sessionStore('navStack', JSON.stringify([home]));
|
||||||
|
navigate(home);
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Back handler error:', e);
|
||||||
|
await CapacitorApp.minimizeApp();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const listenerPromise = CapacitorApp.addListener('backButton', handler); // Bug 1 fix
|
||||||
|
return () => {
|
||||||
|
listenerPromise.then(({ remove }) => remove());
|
||||||
|
};
|
||||||
|
}, [navigate,location.pathname, location.search]);
|
||||||
// mohan
|
// mohan
|
||||||
// useEffect(() => {
|
// useEffect(() => {
|
||||||
// if (isMobile || isIOS) {
|
// if (isMobile || isIOS) {
|
||||||
|
|
@ -211,27 +201,27 @@ const AppRoutes = () => {
|
||||||
|
|
||||||
// return () => clearInterval(checkDevTools);
|
// return () => clearInterval(checkDevTools);
|
||||||
// }, [devToolsOpen]);
|
// }, [devToolsOpen]);
|
||||||
const isBlocked = useDevToolsDetection(() => {
|
// const isBlocked = useDevToolsDetection(() => {
|
||||||
// optional: log, notify, etc.
|
// // optional: log, notify, etc.
|
||||||
console.warn('DevTools detected');
|
// console.warn('DevTools detected');
|
||||||
});
|
// });
|
||||||
|
|
||||||
if (isBlocked) {
|
// if (isBlocked) {
|
||||||
return (
|
// return (
|
||||||
<div style={{
|
// <div style={{
|
||||||
display: 'flex',
|
// display: 'flex',
|
||||||
justifyContent: 'center',
|
// justifyContent: 'center',
|
||||||
alignItems: 'center',
|
// alignItems: 'center',
|
||||||
height: '100vh',
|
// height: '100vh',
|
||||||
flexDirection: 'column',
|
// flexDirection: 'column',
|
||||||
gap: '1rem'
|
// gap: '1rem'
|
||||||
}}>
|
// }}>
|
||||||
<h1 style={{ color: 'red' }}>
|
// <h1 style={{ color: 'red' }}>
|
||||||
DevTools detected. Please close it to continue.
|
// DevTools detected. Please close it to continue.
|
||||||
</h1>
|
// </h1>
|
||||||
</div>
|
// </div>
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
if (extendModel) {
|
if (extendModel) {
|
||||||
return (
|
return (
|
||||||
<ExtendSubscriptionModal
|
<ExtendSubscriptionModal
|
||||||
|
|
|
||||||
|
|
@ -56,12 +56,7 @@ const addAuthHeader = async (config) => {
|
||||||
let encryptedLoginType =
|
let encryptedLoginType =
|
||||||
getSession('LoginType')
|
getSession('LoginType')
|
||||||
|
|
||||||
console.log(
|
|
||||||
'encryptedLoginType',
|
|
||||||
encryptedLoginType,
|
|
||||||
TokendecryptedValuesFun(encryptedMobileno)
|
|
||||||
);
|
|
||||||
|
|
||||||
// let Mobileno = encryptedUserId && encryptedLoginType != "Kiosk" ? TokendecryptedValuesFun(encryptedMobileno) : '1000000001';
|
// let Mobileno = encryptedUserId && encryptedLoginType != "Kiosk" ? TokendecryptedValuesFun(encryptedMobileno) : '1000000001';
|
||||||
let Mobileno = encryptedUserId
|
let Mobileno = encryptedUserId
|
||||||
? encryptedMobileno
|
? encryptedMobileno
|
||||||
|
|
|
||||||
|
|
@ -18,14 +18,14 @@ function RedirectApps() {
|
||||||
const SessionId = encryptedValuesUrlFun(getSession('SessionId'));
|
const SessionId = encryptedValuesUrlFun(getSession('SessionId'));
|
||||||
// const AuthToken = sessionStorage.getItem('auth');
|
// const AuthToken = sessionStorage.getItem('auth');
|
||||||
|
|
||||||
if (sessionStorage.getItem('BranchId') !== null) {
|
if (getSession('BranchId') !== null) {
|
||||||
clearSession('BranchId');
|
clearSession('BranchId');
|
||||||
}
|
}
|
||||||
if (sessionStorage.getItem('AppId') !== null) {
|
if (getSession('AppId') !== null) {
|
||||||
clearSession('AppId');
|
clearSession('AppId');
|
||||||
}
|
}
|
||||||
if (sessionStorage.getItem('hasRefreshed') !== null) {
|
if (getSession('hasRefreshed') !== null) {
|
||||||
sessionStorage.removeItem('hasRefreshed');
|
clearSession('hasRefreshed');
|
||||||
}
|
}
|
||||||
const param = {
|
const param = {
|
||||||
MN: MobileNo,
|
MN: MobileNo,
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ const DateWiseReport = () => {
|
||||||
getSession('AppType')?.toLowerCase() == 'wholesale' ? true : false;
|
getSession('AppType')?.toLowerCase() == 'wholesale' ? true : false;
|
||||||
const [OrderFromDate, setOrderFromDate] = useState();
|
const [OrderFromDate, setOrderFromDate] = useState();
|
||||||
const [OrderToDate, setOrderToDate] = useState();
|
const [OrderToDate, setOrderToDate] = useState();
|
||||||
|
const sessionuserid = getSession('UserId')
|
||||||
const [UserId, setUserId] = useState(
|
const [UserId, setUserId] = useState(
|
||||||
UserRole != 'Employee' ? 0 : getSession('UserId')
|
UserRole != 'Employee' ? 0 : getSession('UserId')
|
||||||
);
|
);
|
||||||
|
|
@ -63,7 +64,7 @@ const DateWiseReport = () => {
|
||||||
setting?.SettingIdName?.toLowerCase() === 'mobilea4' &&
|
setting?.SettingIdName?.toLowerCase() === 'mobilea4' &&
|
||||||
setting?.SettingValue === 'Y'
|
setting?.SettingValue === 'Y'
|
||||||
);
|
);
|
||||||
console.log(MobileA4Print, 'MobileA4PrintMobileA4Print');
|
console.log(MobileA4Print,SettingDataSelector, 'MobileA4PrintMobileA4Print');
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (dataSource?.length > 0) {
|
if (dataSource?.length > 0) {
|
||||||
|
|
@ -368,7 +369,7 @@ const DateWiseReport = () => {
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const getPreference = async () => {
|
const getPreference = async () => {
|
||||||
const data = { AppId: AppId, CompId: CompId, BranchId: BranchId,UserId: UserId };
|
const data = { AppId: AppId, CompId: CompId, BranchId: BranchId,UserId: sessionuserid };
|
||||||
const { data: res } = await dispatch(getPreferenceData(data)).unwrap();
|
const { data: res } = await dispatch(getPreferenceData(data)).unwrap();
|
||||||
const decimalSetting = res?.data?.[0]?.SettingDtlDetails?.find(
|
const decimalSetting = res?.data?.[0]?.SettingDtlDetails?.find(
|
||||||
(setting) =>
|
(setting) =>
|
||||||
|
|
@ -545,12 +546,12 @@ const DateWiseReport = () => {
|
||||||
let TokenData = '';
|
let TokenData = '';
|
||||||
let FooterPrint = '';
|
let FooterPrint = '';
|
||||||
if (isMobile) {
|
if (isMobile) {
|
||||||
if (MobileA4Print) {
|
// if (MobileA4Print) {
|
||||||
ReportMobilePDFPrint({
|
// ReportMobilePDFPrint({
|
||||||
printId: 'RePrint',
|
// printId: 'RePrint',
|
||||||
printStyle: style,
|
// printStyle: style,
|
||||||
});
|
// });
|
||||||
} else {
|
// } else {
|
||||||
var textEncoded = encodeURI(receiptText);
|
var textEncoded = encodeURI(receiptText);
|
||||||
var TypeCheck = 'PrintReceipt';
|
var TypeCheck = 'PrintReceipt';
|
||||||
var scheme = 'pozoprinter';
|
var scheme = 'pozoprinter';
|
||||||
|
|
@ -578,7 +579,7 @@ const DateWiseReport = () => {
|
||||||
FooterPrint +
|
FooterPrint +
|
||||||
'HasFooterTextE' +
|
'HasFooterTextE' +
|
||||||
';end;';
|
';end;';
|
||||||
}
|
// }
|
||||||
} else {
|
} else {
|
||||||
await printDiv('RePrint', style);
|
await printDiv('RePrint', style);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ const ItemWiseReport = () => {
|
||||||
const BranchId = getSession('BranchId');
|
const BranchId = getSession('BranchId');
|
||||||
const AppId = getSession('AppId');
|
const AppId = getSession('AppId');
|
||||||
const UserRole = getSession('UserType');
|
const UserRole = getSession('UserType');
|
||||||
|
const sessionuserid = getSession('UserId')
|
||||||
const [UserId, setUserId] = useState(
|
const [UserId, setUserId] = useState(
|
||||||
UserRole != 'Employee' ? 0 : getSession('UserId')
|
UserRole != 'Employee' ? 0 : getSession('UserId')
|
||||||
);
|
);
|
||||||
|
|
@ -79,7 +80,7 @@ const ItemWiseReport = () => {
|
||||||
setting?.SettingIdName?.toLowerCase() === 'mobilea4' &&
|
setting?.SettingIdName?.toLowerCase() === 'mobilea4' &&
|
||||||
setting?.SettingValue === 'Y'
|
setting?.SettingValue === 'Y'
|
||||||
);
|
);
|
||||||
|
console.log(MobileA4Print,SettingDataSelector, 'MobileA4PrintMobileA4Print')
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getPreference();
|
getPreference();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
@ -210,7 +211,7 @@ const ItemWiseReport = () => {
|
||||||
}
|
}
|
||||||
}, [apiCall]);
|
}, [apiCall]);
|
||||||
const getPreference = async () => {
|
const getPreference = async () => {
|
||||||
const data = { AppId: AppId, CompId: CompId, BranchId: BranchId,UserId: UserId };
|
const data = { AppId: AppId, CompId: CompId, BranchId: BranchId,UserId: sessionuserid };
|
||||||
const { data: res } = await dispatch(getPreferenceData(data)).unwrap();
|
const { data: res } = await dispatch(getPreferenceData(data)).unwrap();
|
||||||
const decimalSetting = res?.data?.[0]?.SettingDtlDetails?.find(
|
const decimalSetting = res?.data?.[0]?.SettingDtlDetails?.find(
|
||||||
(setting) =>
|
(setting) =>
|
||||||
|
|
@ -310,12 +311,12 @@ const ItemWiseReport = () => {
|
||||||
};
|
};
|
||||||
const Print = async () => {
|
const Print = async () => {
|
||||||
if (isMobile) {
|
if (isMobile) {
|
||||||
if (MobileA4Print) {
|
// if (MobileA4Print) {
|
||||||
ReportMobilePDFPrint({
|
// ReportMobilePDFPrint({
|
||||||
printId: 'RePrint',
|
// printId: 'RePrint',
|
||||||
printStyle: style,
|
// printStyle: style,
|
||||||
});
|
// });
|
||||||
} else {
|
// } else {
|
||||||
let LogoImage = '';
|
let LogoImage = '';
|
||||||
let TokenData = '';
|
let TokenData = '';
|
||||||
let FooterPrint = '';
|
let FooterPrint = '';
|
||||||
|
|
@ -346,7 +347,7 @@ const ItemWiseReport = () => {
|
||||||
FooterPrint +
|
FooterPrint +
|
||||||
'HasFooterTextE' +
|
'HasFooterTextE' +
|
||||||
';end;';
|
';end;';
|
||||||
}
|
// }
|
||||||
} else {
|
} else {
|
||||||
await printDiv('RePrint', style);
|
await printDiv('RePrint', style);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -705,7 +705,7 @@
|
||||||
color: #fff;
|
color: #fff;
|
||||||
top: 0;
|
top: 0;
|
||||||
}
|
}
|
||||||
.optionnew:selection {
|
.optionnew::selection {
|
||||||
background-color: #ff4d4f;
|
background-color: #ff4d4f;
|
||||||
}
|
}
|
||||||
.ovrly-icos {
|
.ovrly-icos {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue