Added Qr scann on mobile Funtionalites

This commit is contained in:
Srinath 2026-02-20 15:32:00 +05:30
parent f78d302f1c
commit 4fbce4ec31
1 changed files with 31 additions and 26 deletions

View File

@ -32,6 +32,7 @@ import BarcodeScanner from './BarcodeScanner';
import { isMobile } from 'react-device-detect';
import { BiBarcodeReader } from 'react-icons/bi';
import TooltipWrapper from '../../../../Components/Tooltip/Tooltip';
import BarCodeScan from '../../../../Services/BarCodeScan.jsx';
const BSNavBarComboSearch = (props) => {
@ -1197,28 +1198,28 @@ const BSNavBarComboSearch = (props) => {
: [];
// });
};
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 = (decodedText, err) => {
onChangeprodFunction(decodedText);
setOpenScanner(false); // Close the modal after scanning
stopScannerFromParent();
if (err && err?.error) {
setMessageData(err?.error);
setMessageType('error');
}
};
// const handleQrData = (decodedText, err) => {
// onChangeprodFunction(decodedText);
// setOpenScanner(false); // Close the modal after scanning
// stopScannerFromParent();
// if (err && err?.error) {
// setMessageData(err?.error);
// setMessageType('error');
// }
// };
return (
<div className="L">
<Messages
@ -1289,10 +1290,14 @@ const BSNavBarComboSearch = (props) => {
/>
</div>
{isMobile && screenWidth <= 768 ? (
<BiBarcodeReader
className="search-icon"
onClick={() => handleQrcode()}
/>
// <BiBarcodeReader
// className="search-icon"
// onClick={() => handleQrcode()}
// />
<BarCodeScan
onScan={(value) => {
onChangeprodFunction(value);
}} />
) : (
<IoSearchOutline className="search-icon" />
)}
@ -1395,7 +1400,7 @@ const BSNavBarComboSearch = (props) => {
</div>
</Modal>
)}
{isMobile && screenWidth <= 768 && (
{/* {isMobile && screenWidth <= 768 && (
<DefaultModal
title="Barcode Reader"
width={800}
@ -1413,7 +1418,7 @@ const BSNavBarComboSearch = (props) => {
/>
)}
</DefaultModal>
)}
)} */}
</div>
);
};