diff --git a/src/components/fingerprint-scanner.js b/src/components/fingerprint-scanner.js index 1c5024e..62f0813 100644 --- a/src/components/fingerprint-scanner.js +++ b/src/components/fingerprint-scanner.js @@ -2,29 +2,40 @@ import { Box, Typography, Button } from "@mui/material"; import FingerprintImg from "../images/fp_3.png"; import { useAppContext } from "../context/appContext"; import { useNavigate } from "react-router-dom"; -import { useEffect } from "react"; +import { useEffect,useState } from "react"; import { socket } from "../utils/socket" -const FingerprintScanner = ({ isStudent, setIsBioLogin, examId }) => { +const FingerprintScanner = ({ isStudent, setIsBioLogin, examId, setPerson1, setMessage1, setOpen }) => { const { loginSupervisor, loginStudent } = useAppContext(); const navigate = useNavigate(); + console.log(setPerson1) - // TODO - call this when fingerprint scanning finished const handleLogIn = (fingerprint) => { - // TODO - Get fingerprint from the input scanner device + const typedArray = new Uint8Array(fingerprint['1']['buffer']); + const temp = [...typedArray]; + const fingerData = {fingerprint:{bioSubType:fingerprint['1']['bioSubType'], buffer:{data: temp}}, eventId:Number(examId)} if (!isStudent) { - loginSupervisor(fingerprint); + loginSupervisor(fingerData); + console.log("Here"); } else { - loginStudent(fingerprint); + const data = loginStudent(fingerData); + console.log(data); + setPerson1(data.person); + setMessage1(data.message); + setOpen(true); } }; useEffect(() => { socket.on("fingerprintData", async (fingerprintData) => { - handleLogIn(fingerprintData) + if (fingerprintData.success === undefined){ + handleLogIn(fingerprintData) + + }else{ + console.log("fingerprint not successfull") + } }); - requestFingerprint() }, []); async function requestFingerprint() { @@ -41,6 +52,17 @@ const FingerprintScanner = ({ isStudent, setIsBioLogin, examId }) => { alt="fingerprint" style={{ margin: "10%" }} /> + {isStudent && ( + + )} {isStudent && (