Added Qr scann on mobile Funtionalites

This commit is contained in:
Srinath 2026-02-20 15:33:21 +05:30
parent 03ff3e0218
commit c6fdfe5842
1 changed files with 31 additions and 25 deletions

View File

@ -37,6 +37,7 @@ import { BiBarcodeReader } from 'react-icons/bi';
import { ApplicationPreferences } from '../../../../Features/BrachLogin/BranchLogin.js';
import { useDateStore } from '../../../../Features/BookingScreen/BookingData/DateStore.js';
import { Messages } from '../../../../../ownLib/my-ui-lib.js';
import BarCodeScan from '../../../../Services/BarCodeScan.jsx';
const BSNavBarSearch = (props) => {
const searchInputRef = useRef(null);
@ -362,28 +363,28 @@ const BSNavBarSearch = (props) => {
await dispatch(getCardDataWithoutSub(data));
};
const stopScannerFromParent = () => {
if (scannerRef?.current) {
scannerRef?.current?.stopScanner(); // Call stopScanner from the child component
}
};
// const stopScannerFromParent = () => {
// if (scannerRef?.current) {
// scannerRef?.current?.stopScanner(); // Call stopScanner from the child component
// }
// };
const handleQrcode = () => {
setOpenScanner((prev) => !prev);
if (!openScanner && scannerRef?.current) {
scannerRef?.current?.reinitializeCamera(); // Call the function to reinitialize the camera
}
};
// const handleQrcode = () => {
// setOpenScanner((prev) => !prev);
// if (!openScanner && scannerRef?.current) {
// scannerRef?.current?.reinitializeCamera(); // Call the function to reinitialize the camera
// }
// };
const handleQrData = async (value, err) => {
if (err && err?.error) {
setMessageData(err?.error);
setMessageType('error');
}
await searchdata(value);
setOpenScanner(false);
stopScannerFromParent();
};
// const handleQrData = async (value, err) => {
// if (err && err?.error) {
// setMessageData(err?.error);
// setMessageType('error');
// }
// await searchdata(value);
// setOpenScanner(false);
// stopScannerFromParent();
// };
const onComplete = useCallback(() => {
setMessageData(null);
@ -421,9 +422,14 @@ const BSNavBarSearch = (props) => {
disabled={props.OrderType === 'Failed' ? true : false}
/>
{isMobile && screenWidth <= 768 ? (
<BiBarcodeReader
className="search-icon"
onClick={() => handleQrcode()}
// <BiBarcodeReader
// className="search-icon"
// onClick={() => handleQrcode()}
// />
<BarCodeScan
onScan={(value) => {
searchdata(value);
}}
/>
) : (
<IoSearchOutline className="search-icon" />
@ -435,7 +441,7 @@ const BSNavBarSearch = (props) => {
</div>} */}
</div>
</div>
{isMobile && screenWidth <= 768 && (
{/* {isMobile && screenWidth <= 768 && (
<DefaultModal
title="Barcode Reader"
width={800}
@ -454,7 +460,7 @@ const BSNavBarSearch = (props) => {
/>
)}
</DefaultModal>
)}
)} */}
</div>
);
};