From a2efb769de545993929eccbe29f7a75e421b1483 Mon Sep 17 00:00:00 2001 From: Pradeeppon01 Date: Thu, 4 Jul 2024 13:10:42 +0530 Subject: [PATCH] latest --- src/Components/BarcodeScanner.jsx | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/Components/BarcodeScanner.jsx b/src/Components/BarcodeScanner.jsx index 04ce41c..377210d 100644 --- a/src/Components/BarcodeScanner.jsx +++ b/src/Components/BarcodeScanner.jsx @@ -19,11 +19,11 @@ const BarcodeScanner = () => { fps: 5, }); - const fetchBarcodeData = (result) => { + const fetchBarcodeData = () => { setIsLoading(true); try { const payload = { - qrcodeValue: result, + qrcodeValue: scanResult, }; fetch( `${ @@ -50,6 +50,7 @@ const BarcodeScanner = () => { throw new Error(error); } }; + window.fetchBarcodeData = fetchBarcodeData; const success = (result) => { // scannerRef.current.clear(); @@ -58,14 +59,13 @@ const BarcodeScanner = () => { readerEle.style.visibility = "hidden"; } setScanResult(result); - fetchBarcodeData(result); }; - window.success = success + window.success = success; const error = (err) => { console.log("Error: ", err); }; - window.error = error + window.error = error; // Ensure the element is in the DOM before initializing the scanner if (document.getElementById("reader")) { scannerRef.current.render(success, error); @@ -96,6 +96,8 @@ const BarcodeScanner = () => { readerEle.style.visibility = "visible"; scannerRef.current.render(success, error); } + } else { + fetchBarcodeData(); } }, [scanResult]); @@ -152,8 +154,18 @@ const BarcodeScanner = () => { ) : ( - -
Marks Data Not Found ..
+ + +
Marks Data Not Found ..
+
+ + +
) ) : null}