This commit is contained in:
Pradeeppon01 2024-07-13 19:29:10 +05:30
parent c31458330b
commit aee9f5c534
1 changed files with 20 additions and 5 deletions

View File

@ -8,6 +8,7 @@ const BarcodeScanner = () => {
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
const [barcodeInfo, setBarcodeInfo] = useState([]); const [barcodeInfo, setBarcodeInfo] = useState([]);
const [marksData, setMarksData] = useState([]); const [marksData, setMarksData] = useState([]);
const [partAData, setPartAData] = useState([]);
const scannerRef = useRef(null); // Use ref to store the scanner instance const scannerRef = useRef(null); // Use ref to store the scanner instance
useEffect(() => { useEffect(() => {
@ -21,9 +22,12 @@ const BarcodeScanner = () => {
const fetchBarcodeData = () => { const fetchBarcodeData = () => {
if (!scanResult) { if (!scanResult) {
return return;
} }
setIsLoading(true); setIsLoading(true);
setMarksData([])
setBarcodeInfo([])
setPartAData([])
try { try {
const payload = { const payload = {
qrcodeValue: scanResult, qrcodeValue: scanResult,
@ -46,6 +50,7 @@ const BarcodeScanner = () => {
if (responseData.status === "success") { if (responseData.status === "success") {
setBarcodeInfo(responseData.results); setBarcodeInfo(responseData.results);
setMarksData(responseData?.marks); setMarksData(responseData?.marks);
setPartAData(responseData?.partAResults);
} }
}); });
} catch (error) { } catch (error) {
@ -110,20 +115,20 @@ const BarcodeScanner = () => {
<h1>Welcome to exampaper.vidh.ai</h1> <h1>Welcome to exampaper.vidh.ai</h1>
</Box> </Box>
<Box className="my-3"> <Box className="my-3">
<Box className="d-none d-md-flex justify-content-center align-items-center w-100"> <Box className="d-flex justify-content-center align-items-center w-100">
{scanResult ? ( {scanResult ? (
<h5>QR : {scanResult}</h5> <h5>QR : {scanResult}</h5>
) : ( ) : (
<div id="reader" style={{ width: "400px", height: "400px" }}></div> <div id="reader" style={{ width: "400px", height: "400px" }}></div>
)} )}
</Box> </Box>
<Box className="d-flex d-md-none justify-content-center align-items-center w-100"> {/* <Box className="d-flex d-md-none justify-content-center align-items-center w-100">
{scanResult ? ( {scanResult ? (
<h5>QR : {scanResult}</h5> <h5>QR : {scanResult}</h5>
) : ( ) : (
<div id="reader" style={{ width: "400px", height: "400px" }}></div> <div id="reader" style={{ width: "400px", height: "400px" }}></div>
)} )}
</Box> </Box> */}
</Box> </Box>
<Box className="w-100 d-flex justify-content-center"> <Box className="w-100 d-flex justify-content-center">
{barcodeInfo.length > 0 && ( {barcodeInfo.length > 0 && (
@ -135,6 +140,15 @@ const BarcodeScanner = () => {
<h5>Exam center : {barcodeInfo[0]?.exam_center}</h5> <h5>Exam center : {barcodeInfo[0]?.exam_center}</h5>
</Box> </Box>
)} )}
{partAData.length > 0 && (
<Box className="p-5 w-50 rounded shadow">
<h5>Barcode : {partAData[0]?.barcode}</h5>
<h5>QRcode : {partAData[0]?.qrcode}</h5>
<h5>S.NO : {barcodeInfo[0]?.slno}</h5>
<h5>Booklet No : {barcodeInfo[0]?.booklet_serial_no}</h5>
<img src={`https://docs.exampaper.vidh.ai/${partAData?.s3_path}`} alt="PartA Image" width="50%" height="auto"/>
</Box>
)}
</Box> </Box>
<Box className="w-100 d-flex justify-content-center"> <Box className="w-100 d-flex justify-content-center">
{scanResult ? ( {scanResult ? (
@ -145,6 +159,7 @@ const BarcodeScanner = () => {
<h5>Marks : {marksData[0]?.marks}</h5> <h5>Marks : {marksData[0]?.marks}</h5>
<h5>File Scanned Date : {marksData[0]?.file_scanned_date}</h5> <h5>File Scanned Date : {marksData[0]?.file_scanned_date}</h5>
<h5>Cover QR code : {marksData[0]?.cover_barcode}</h5> <h5>Cover QR code : {marksData[0]?.cover_barcode}</h5>
<img src={`https://docs.exampaper.vidh.ai/${marksData?.s3_path}`} alt="PartC Image" width="50%" height="auto"/>
</Box> </Box>
<Box> <Box>
<Button <Button