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