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