From 72776c2008e7905b3dd948d9e9decb91c86c7207 Mon Sep 17 00:00:00 2001 From: Pradeeppon01 Date: Wed, 7 Aug 2024 17:26:22 +0530 Subject: [PATCH] latest --- index.html | 2 +- src/App.jsx | 52 ++- src/Components/AnomolyAttendencePage.jsx | 80 ++--- src/Components/Home.jsx | 7 +- .../PendingAttendenceCorrection.jsx | 325 ++++++++++++++++++ src/Components/QrcodeFinder.jsx | 290 ++++++++++++++++ 6 files changed, 698 insertions(+), 58 deletions(-) create mode 100644 src/Components/PendingAttendenceCorrection.jsx create mode 100644 src/Components/QrcodeFinder.jsx diff --git a/index.html b/index.html index f865f85..8e2465e 100644 --- a/index.html +++ b/index.html @@ -12,7 +12,7 @@ exampaper.vidh.ai -
+
diff --git a/src/App.jsx b/src/App.jsx index 9aa02b1..542dc1e 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -21,17 +21,18 @@ import RecordEditor from "./Components/RecordEditor"; import VerifyMarks from "./Components/VerifyMarks"; import QueryCardEditor from "./Components/QueryCardEditor"; import AnomolyPartC from "./Components/AnomolyPartC"; -import BarcodeScanner from "./Components/BarcodeScanner" +import BarcodeScanner from "./Components/BarcodeScanner"; import EvQrcode from "./Components/EvQrcode"; import QrcodeCardEditor from "./Components/QrCodeCardEditor"; import StudentResultsData from "./Components/StudentsResultsData"; import PlayGrounds from "./Components/PlayGrounds"; import PlayGround from "./Components/PlayGround"; import Revaluation from "./Components/Revaluation"; -import PlayGroundUpdated from "./Components/PlaygroundUpdated" +import PlayGroundUpdated from "./Components/PlaygroundUpdated"; import DummyDuplicates from "./Components/DummyDuplicates"; import IndividualStudAttendence from "./Components/IndividualStudAttendence"; - +import PendingAttendenceCorrection from "./Components/PendingAttendenceCorrection"; +import QrcodeFinder from "./Components/QrcodeFinder"; function App() { return ( @@ -40,31 +41,47 @@ function App() { }> }> - }> - }> - }> - }> - }> - }> - }> + } + > + }> + } + > + }> + }> + }> + } + > } > - } + } + /> + } > } > - }> + } + > } > - }> + }> } @@ -77,6 +94,7 @@ function App() { path="/anomoly/attendence" element={} > + }> } @@ -100,8 +118,8 @@ function App() { path="/anomoly/partA/booklet" element={} > - }> - }> + }> + }> diff --git a/src/Components/AnomolyAttendencePage.jsx b/src/Components/AnomolyAttendencePage.jsx index db103b6..071e060 100644 --- a/src/Components/AnomolyAttendencePage.jsx +++ b/src/Components/AnomolyAttendencePage.jsx @@ -1,44 +1,46 @@ import { Box } from "@mui/material"; import HomepageCard from "./HomepageCard"; -import {useState,useEffect} from "react" +import { useState, useEffect } from "react"; + +const AnomolyAttendencePage = () => { + const cards = [ + { + title: "Reassigned Serial Number Updation", + url: "/anomoly/attendence/reassigned", + }, + // { + // title: "Additional Student Record Insertion", + // url: "/anomoly/attendence/additionalRecord", + // }, + { + title: "Additional Sheet Insertion", + url: "/anomoly/attendence/additionalSheet", + }, + { + title: "Individual Attendence Sheet Check", + url: "/anomoly/attendence/stud_check", + }, + { + title: "Pending Attendence Correction", + url: "/anomoly/attendence/pending_stud_check", + }, + ]; -const AnomolyAttendencePage = () =>{ - const cards = [ - { - title: "Reassigned Serial Number Updation", - url: "/anomoly/attendence/reassigned" - }, - // { - // title: "Additional Student Record Insertion", - // url: "/anomoly/attendence/additionalRecord", - // }, - { - title: "Additional Sheet Insertion", - url: "/anomoly/attendence/additionalSheet", - }, - { - title: "Individual Attendence Sheet Check", - url: "/anomoly/attendence/stud_check", - } - ] + return ( + <> + + +

Welcome to exampaper.vidh.ai

+
+ + {cards.map((card) => ( + + ))} + +
+ + ); +}; - return ( - <> - - -

Welcome to exampaper.vidh.ai

-
- - {cards.map((card) => ( - - ))} - -
- - ); -} - - - -export default AnomolyAttendencePage; \ No newline at end of file +export default AnomolyAttendencePage; diff --git a/src/Components/Home.jsx b/src/Components/Home.jsx index b4d7a1c..fad5d6d 100644 --- a/src/Components/Home.jsx +++ b/src/Components/Home.jsx @@ -3,6 +3,7 @@ import HomepageCard from "./HomepageCard"; import {useState,useEffect} from "react" import Notification from "./Notification"; + const Home = () => { const cards = [ { @@ -33,6 +34,10 @@ const Home = () => { title:"SQL Playground", url:"/sqlPlayground" }, + { + title:"QR Code Finder", + url:"/qrcodeFinder" + }, { title:"QR Code Scanner", url:"/barcodeScanner" @@ -67,7 +72,7 @@ const Home = () => { return ( <> - +

Welcome to exampaper.vidh.ai

diff --git a/src/Components/PendingAttendenceCorrection.jsx b/src/Components/PendingAttendenceCorrection.jsx new file mode 100644 index 0000000..5df0784 --- /dev/null +++ b/src/Components/PendingAttendenceCorrection.jsx @@ -0,0 +1,325 @@ +import React, { useState, useEffect } from "react"; +import { Box, Button } from "@mui/material"; +import AntdesignLayout from "./AntdesignLayout"; +import LoadingContainer from "./LoadingContainer"; +import infinity_loader from "../../assets/Infinity_loader.gif"; +import Notification from "./Notification"; // Import the Notification component +import { Height } from "@mui/icons-material"; +import ZoomInIcon from "@mui/icons-material/ZoomIn"; +import ZoomOutIcon from "@mui/icons-material/ZoomOut"; +import ArrowBackIcon from "@mui/icons-material/ArrowBack"; +import ArrowForwardIcon from "@mui/icons-material/ArrowForward"; + +const PendingAttendenceCorrection = () => { + const [registerNumber, setRegisterNumber] = useState(null); + const [subjectCode, setSubjectCode] = useState(null); + const [attendenceSerialNo, setAttendenceSerialNo] = useState(null); + const [isLoading, setIsLoading] = useState(false); + const [attendenceResults, setAttendenceResults] = useState(null); + const [zoomValue, setZoomValue] = useState(950); + const [absentStatus, setAbsentStatus] = useState(-1); + const [notification, setNotification] = useState(null); // Notification state + const [type, setType] = useState(null); + const [attendenceIndex, setAttendenceIndex] = useState(0); + + const showNotification = (message, type) => { + setNotification({ message, type }); + }; + + useEffect(() => { + const fetchingPendingData = async () => { + setType(1); + setIsLoading(true); + try { + const response = await fetch( + `${ + import.meta.env.VITE_REACT_APP_BACKEND_URL + }/fetchPendingAttendenceData`, + { + method: "GET", + } + ); + + const responseData = await response.json(); + console.log("The response data ===== ", responseData); + setIsLoading(false); + if (responseData?.status === "success") { + setAttendenceResults(responseData?.attendence_results); + } + } catch (error) { + setIsLoading(false); + console.error("Error updating student status:", error); + } + }; + fetchingPendingData(); + }, []); + + const updateStudentStatus = async () => { + setIsLoading(true); + try { + const payload = { + attendenceResults, + absentStatus, + attendenceSerialNo, + register_number: registerNumber, + subject_code: subjectCode, + }; + + const response = await fetch( + `${ + import.meta.env.VITE_REACT_APP_BACKEND_URL + }/updateStudentAttendenceStatus`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(payload), + } + ); + + const responseData = await response.json(); + console.log("The response data ===== ", responseData); + + if (responseData?.status === "success") { + setAttendenceIndex((prev) => prev + 1); + showNotification("Record updated successfully !!", "success"); + setAbsentStatus(-1) + } + setIsLoading(false); + } catch (error) { + setIsLoading(false); + console.error("Error updating student status:", error); + showNotification("Error updating student status", "error"); + } + }; + + useEffect(() => { + console.log("Absent status changed ==== ", absentStatus); + if (Number(absentStatus) === 0 || Number(absentStatus) === 1) { + updateStudentStatus(); + } + }, [absentStatus]); + + const fetchAttendenceData = async () => { + setAbsentStatus(-1); + if (!attendenceSerialNo) { + if (!registerNumber || !subjectCode) { + showNotification( + "Registration Number && Subject Code is Mandatory !!", + "error" + ); + return; + } + } + if (registerNumber && subjectCode) { + setType(1); + } else if (attendenceSerialNo) { + setType(2); + } + setIsLoading(true); + try { + const payload = { + registerNumber, + subjectCode, + attendenceSerialNo, + }; + + const response = await fetch( + `${import.meta.env.VITE_REACT_APP_BACKEND_URL}/fetchAttendenceData`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(payload), + } + ); + + const responseData = await response.json(); + console.log("response data ========= ", responseData); + setIsLoading(false); + if (responseData?.status === "success") { + setType(responseData?.type); + const modifiedResponseData = responseData?.results; + console.log("attendence response data ===== ", modifiedResponseData); + if (modifiedResponseData) { + setAttendenceResults((prevResults) => { + const newAttendenceData = [...prevResults]; + newAttendenceData[attendenceIndex] = modifiedResponseData; + console.log("new attendence data ==== ", newAttendenceData); + return newAttendenceData; + }); + } + } + } catch (error) { + setIsLoading(false); + console.error("Error fetching attendance data:", error); + showNotification("Error fetching attendance data", "error"); + } + }; + + useEffect(() => { + if (attendenceResults?.length > 0) { + setRegisterNumber(attendenceResults[attendenceIndex]?.register_number); + setSubjectCode(attendenceResults[attendenceIndex]?.subject_code); + } + }, [attendenceIndex, attendenceResults]); + + return ( + + {/* +
+ + setRegisterNumber(e.target.value)} + /> +
+
+ + setSubjectCode(e.target.value)} + /> +
+
+ + setAttendenceSerialNo(e.target.value)} + /> +
+ +
*/} + {attendenceResults?.length > 0 && ( + + + {Object.keys(attendenceResults[attendenceIndex]).map( + (key, index) => ( + + + {key} : {attendenceResults[attendenceIndex][key]} + + + ) + )} + {type === 1 && ( + <> + + + + + + )} + + + + + {attendenceIndex + 1 + " / " + attendenceResults.length} + + + + + + + + + + {attendenceResults.length > 0 && type === 2 && ( + Attendence-image + )} + {attendenceResults.length > 0 && type === 1 && ( + Attendence-image + )} + + + + )} + {attendenceResults?.length == 0 && ( + Attendence Record Not Found !! + )} + {isLoading && } + {notification && ( + setNotification(null)} + /> + )} +
+ ); +}; + +export default PendingAttendenceCorrection; diff --git a/src/Components/QrcodeFinder.jsx b/src/Components/QrcodeFinder.jsx new file mode 100644 index 0000000..60016a8 --- /dev/null +++ b/src/Components/QrcodeFinder.jsx @@ -0,0 +1,290 @@ +import React, { useState, useEffect } from "react"; +import { Box, Button } from "@mui/material"; +import AntdesignLayout from "./AntdesignLayout"; +import LoadingContainer from "./LoadingContainer"; +import infinity_loader from "../../assets/Infinity_loader.gif"; +import Notification from "./Notification"; // Import the Notification component +import { Height } from "@mui/icons-material"; +import ZoomInIcon from "@mui/icons-material/ZoomIn"; +import ZoomOutIcon from "@mui/icons-material/ZoomOut"; + +const QrcodeFinder = () => { + const [registerNumber, setRegisterNumber] = useState(null); + const [subjectCode, setSubjectCode] = useState(null); + const [attendenceSerialNo, setAttendenceSerialNo] = useState(null); + const [isLoading, setIsLoading] = useState(false); + const [attendenceResults, setAttendenceResults] = useState(null); + const [zoomValue, setZoomValue] = useState(950); + const [absentStatus, setAbsentStatus] = useState(-1); + const [notification, setNotification] = useState(null); // Notification state + const [type, setType] = useState(null); + const [coverBarcode, setCoverBarcode] = useState(null); + const [pdfPath, setPdfPath] = useState(null); + const [coverInfo, setCoverInfo] = useState(null); + const [pdfData, setPdfData] = useState(null); + + const showNotification = (message, type) => { + setNotification({ message, type }); + }; + + const updateStudentStatus = async () => { + setIsLoading(true); + try { + const payload = { + attendenceResults, + absentStatus, + attendenceSerialNo, + register_number: registerNumber, + subject_code: subjectCode, + }; + + const response = await fetch( + `${ + import.meta.env.VITE_REACT_APP_BACKEND_URL + }/updateStudentAttendenceStatus`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(payload), + } + ); + + const responseData = await response.json(); + console.log("The response data ===== ", responseData); + + if (responseData?.status === "success") { + fetchAttendenceData(); + showNotification("Record updated successfully !!", "success"); + } + setIsLoading(false); + } catch (error) { + setIsLoading(false); + console.error("Error updating student status:", error); + showNotification("Error updating student status", "error"); + } + }; + + useEffect(() => { + console.log("Absent status changed ==== ", absentStatus); + if (Number(absentStatus) === 0 || Number(absentStatus) === 1) { + updateStudentStatus(); + } + }, [absentStatus]); + + const fetchAttendenceData = async () => { + setAbsentStatus(-1); + if (!attendenceSerialNo) { + if (!registerNumber || !subjectCode) { + showNotification( + "Registration Number && Subject Code is Mandatory !!", + "error" + ); + return; + } + } + if (registerNumber && subjectCode) { + setType(1); + } else if (attendenceSerialNo) { + setType(2); + } + setIsLoading(true); + try { + const payload = { + registerNumber, + subjectCode, + attendenceSerialNo, + }; + + const response = await fetch( + `${import.meta.env.VITE_REACT_APP_BACKEND_URL}/fetchAttendenceData`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(payload), + } + ); + + const responseData = await response.json(); + console.log("response data ========= ", responseData); + setIsLoading(false); + if (responseData?.status === "success") { + setAttendenceResults(responseData?.results); + setType(responseData?.type); + } + } catch (error) { + setIsLoading(false); + console.error("Error fetching attendance data:", error); + showNotification("Error fetching attendance data", "error"); + } + }; + + const fetchCoverCodeInfo = async () => { + if (!coverBarcode && !pdfPath) { + showNotification("CoverBarcode or Pdf path is mandatory !!", "error"); + return; + } + setCoverInfo(null) + setPdfData(null) + setIsLoading(true); + try { + const payload = { + coverBarcode, + pdfPath, + }; + + const response = await fetch( + `${import.meta.env.VITE_REACT_APP_BACKEND_URL}/fetchCoverBarcode`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(payload), + } + ); + + const responseData = await response.json(); + console.log("response data ========= ", responseData); + setIsLoading(false); + if (responseData?.status === "success") { + setCoverInfo(responseData?.ev_results); + setPdfData(responseData?.part_c_results); + } + } catch (error) { + setIsLoading(false); + console.error("Error fetching attendance data:", error); + showNotification("Error fetching attendance data", "error"); + } + }; + + return ( + + +
+ + setCoverBarcode(e.target.value)} + style={{ width: "600px" }} + /> +
+
+ + setPdfPath(e.target.value)} + /> +
+ +
+ {coverInfo && coverInfo?.length === 0 && Cover Info Not Found} + + {coverInfo && coverInfo?.length > 0 && ( + + + Cover Info : + + + + )} + + {pdfData && pdfData.length > 0 && ( + + PDF Info - {pdfData.length} Pages + + )} + + {pdfData && + pdfData.length > 0 && + pdfData.map((data, index) => ( + + + {index + 1 + "/" + pdfData.length} + + + {" "} + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Register Number + {data?.register_number || "NULL"} +
Subject Code + {data?.subject_code || "NULL"} +
Marks{data?.marks || "NULL"}
Marks R1 + {data?.marks_R1 || "NULL"} +
Marks R2 + {data?.marks_R2 || "NULL"} +
Page Number + {data?.page_number || "NULL"} +
+
+
+ ))} +
+
+
+ {isLoading && } + {notification && ( + setNotification(null)} + /> + )} +
+ ); +}; + +export default QrcodeFinder;