latest
This commit is contained in:
parent
23d11e68a9
commit
a2efb769de
|
|
@ -19,11 +19,11 @@ const BarcodeScanner = () => {
|
||||||
fps: 5,
|
fps: 5,
|
||||||
});
|
});
|
||||||
|
|
||||||
const fetchBarcodeData = (result) => {
|
const fetchBarcodeData = () => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
const payload = {
|
const payload = {
|
||||||
qrcodeValue: result,
|
qrcodeValue: scanResult,
|
||||||
};
|
};
|
||||||
fetch(
|
fetch(
|
||||||
`${
|
`${
|
||||||
|
|
@ -50,6 +50,7 @@ const BarcodeScanner = () => {
|
||||||
throw new Error(error);
|
throw new Error(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
window.fetchBarcodeData = fetchBarcodeData;
|
||||||
|
|
||||||
const success = (result) => {
|
const success = (result) => {
|
||||||
// scannerRef.current.clear();
|
// scannerRef.current.clear();
|
||||||
|
|
@ -58,14 +59,13 @@ const BarcodeScanner = () => {
|
||||||
readerEle.style.visibility = "hidden";
|
readerEle.style.visibility = "hidden";
|
||||||
}
|
}
|
||||||
setScanResult(result);
|
setScanResult(result);
|
||||||
fetchBarcodeData(result);
|
|
||||||
};
|
};
|
||||||
window.success = success
|
window.success = success;
|
||||||
|
|
||||||
const error = (err) => {
|
const error = (err) => {
|
||||||
console.log("Error: ", err);
|
console.log("Error: ", err);
|
||||||
};
|
};
|
||||||
window.error = error
|
window.error = error;
|
||||||
// Ensure the element is in the DOM before initializing the scanner
|
// Ensure the element is in the DOM before initializing the scanner
|
||||||
if (document.getElementById("reader")) {
|
if (document.getElementById("reader")) {
|
||||||
scannerRef.current.render(success, error);
|
scannerRef.current.render(success, error);
|
||||||
|
|
@ -96,6 +96,8 @@ const BarcodeScanner = () => {
|
||||||
readerEle.style.visibility = "visible";
|
readerEle.style.visibility = "visible";
|
||||||
scannerRef.current.render(success, error);
|
scannerRef.current.render(success, error);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
fetchBarcodeData();
|
||||||
}
|
}
|
||||||
}, [scanResult]);
|
}, [scanResult]);
|
||||||
|
|
||||||
|
|
@ -152,9 +154,19 @@ const BarcodeScanner = () => {
|
||||||
</Box>
|
</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>
|
<h5>Marks Data Not Found ..</h5>
|
||||||
</Box>
|
</Box>
|
||||||
|
<Box className="my-3">
|
||||||
|
<Button
|
||||||
|
className="p-3 bg-primary text-light rounded"
|
||||||
|
onClick={reinitializeScanner}
|
||||||
|
>
|
||||||
|
Scan Again
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
)
|
)
|
||||||
) : null}
|
) : null}
|
||||||
</Box>
|
</Box>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue