latest
This commit is contained in:
parent
23d11e68a9
commit
a2efb769de
|
|
@ -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,9 +154,19 @@ const BarcodeScanner = () => {
|
|||
</Box>
|
||||
</>
|
||||
) : (
|
||||
<Box className="p-5 w-50 rounded shadow">
|
||||
<Box className="w-50">
|
||||
<Box className="p-5 rounded shadow">
|
||||
<h5>Marks Data Not Found ..</h5>
|
||||
</Box>
|
||||
<Box className="my-3">
|
||||
<Button
|
||||
className="p-3 bg-primary text-light rounded"
|
||||
onClick={reinitializeScanner}
|
||||
>
|
||||
Scan Again
|
||||
</Button>
|
||||
</Box>
|
||||
</Box>
|
||||
)
|
||||
) : null}
|
||||
</Box>
|
||||
|
|
|
|||
Loading…
Reference in New Issue