From f29a3bab0045a5e46cab271ea5a4f376cc1ba7bc Mon Sep 17 00:00:00 2001 From: Pradeeppon01 Date: Sun, 12 Jan 2025 23:25:11 +0530 Subject: [PATCH] latest --- .env | 4 +- src/App.css | 3 +- .../AttendenceNotShadedCorrection.jsx | 273 +++++++++++++++++- src/Components/HomeSections.jsx | 8 +- 4 files changed, 276 insertions(+), 12 deletions(-) diff --git a/.env b/.env index 3c38fb2..a3327dd 100644 --- a/.env +++ b/.env @@ -1,6 +1,6 @@ #VITE_REACT_APP_BACKEND_URL="https://sandbox.exampaper.vidh.ai" METABASE_BASE_URL="http://metabase.usln.in/public/question/d8774923-09bb-4cd9-903b-559d417e12cf" -VITE_REACT_APP_BACKEND_URL="http://localhost:9999" -# VITE_REACT_APP_BACKEND_URL="https://api.dev.exampaper.usln.in" +# VITE_REACT_APP_BACKEND_URL="http://localhost:9999" +VITE_REACT_APP_BACKEND_URL="https://api.dev.exampaper.usln.in" #VITE_REACT_APP_BACKEND_URL="https://api.exampaper.usln.in" diff --git a/src/App.css b/src/App.css index 1e6d588..5b688f7 100644 --- a/src/App.css +++ b/src/App.css @@ -90,7 +90,8 @@ } .grey-background{ - background-color: rgba(128, 128, 128, 0.1); + /* background-color: rgba(128, 128, 128, 0.1); */ + background-color: rgba(3, 133, 8, 0.1); } diff --git a/src/Components/AttendenceNotShadedCorrection.jsx b/src/Components/AttendenceNotShadedCorrection.jsx index 2320a81..d9617b3 100644 --- a/src/Components/AttendenceNotShadedCorrection.jsx +++ b/src/Components/AttendenceNotShadedCorrection.jsx @@ -1,8 +1,271 @@ -const AttendenceNotShadedCorrection = () =>{ - return( -
Hl
+import { useAsyncError } from "react-router-dom"; +import AntdesignLayout from "./AntdesignLayout"; +import { useState, useEffect } from "react"; +import { useParams } from "react-router-dom"; +import { Box, Button } from "@mui/material"; +import LoadingContainer from "./LoadingContainer"; +import Notification from "./Notification"; +import SystemNumberDialog from "./SystemNumberDialog"; +import { useSelector, useDispatch } from "react-redux"; +import { Layout, theme, Pagination } from "antd"; +const { Content, Header } = Layout; +import { useNavigate } from "react-router-dom"; +import ArrowBackIcon from "@mui/icons-material/ArrowBack"; +import HomeIcon from "@mui/icons-material/Home"; + +const AttendenceNotShadedCorrection = () => { + const { year } = useParams(); + const navigate = useNavigate(); + const [AttendenceData, setAttendenceData] = useState([]); + const [notification, setNotification] = useState(null); + const [isLoading, setIsLoading] = useState(false); + const [showSystemNoContainer, setShowSystemNoContainer] = useState(false); + + const reduxSystemNo = useSelector((state) => state?.systemNumber); + console.log("systemno: ", reduxSystemNo); + + const { + token: { colorBgContainer, borderRadiusLG }, + } = theme.useToken(); + + const imageDomain = + year === "april2024" + ? "https://docs.exampaper.vidh.ai" + : year === "november2024" + ? "https://images.exampaper.usln.in" + : "https://docs.exampaper.vidh.ai"; + + const showNotification = (message, type) => { + setNotification({ message, type }); + }; + + const FetchAttendenceNotShadedCorrection = (reduxSystemNo) => { + console.log("Fetching......."); + setIsLoading(true); + fetch( + `${ + import.meta.env.VITE_REACT_APP_BACKEND_URL + }/fetchAttendenceNotShaded?systemNo=${reduxSystemNo}`, + { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + } ) -} + .then((response) => { + console.log("Response fetched.."); + return response.json(); + }) + .then((responseData) => { + console.log("Response Data is : ", responseData); + setIsLoading(false); + if (responseData.status === "success") { + setAttendenceData(responseData?.data); + } + }) + .catch((error) => { + console.error("Error fetching data: ", error); + setIsLoading(false); + }); + }; + const updateStatus = (type, data, index) => { + console.log("Fetching......."); + setIsLoading(true); + const payload = { + year, + type, + data, + }; + fetch( + `${import.meta.env.VITE_REACT_APP_BACKEND_URL}/updateAttendenceStatus`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(payload), + } + ) + .then((response) => { + console.log("Response fetched.."); + return response.json(); + }) + .then((responseData) => { + console.log("Response Data is : ", responseData); + setIsLoading(false); + if (responseData.status === "success") { + showNotification( + `Record Record as ${type} Successfully...`, + "success" + ); + const newData = data; + const tmpDatas = AttendenceData; + newData.verified = 1; + if (type == "OMIT") { + newData.omitted = 1; + newData.absent_status = null; + newData.verified = 1; + } else if (type == "ABSENT") { + newData.omitted = null; + newData.absent_status = 1; + newData.verified = 1; + } else if (type == "PRESENT") { + newData.omitted = null; + newData.absent_status = 0; + newData.verified = 1; + } + tmpDatas[index] = newData; + setAttendenceData(tmpDatas); + const mainEle = document.getElementById( + `attendence_data_container_${index}` + ); + if (mainEle) { + console.log("main Ele === ", mainEle); + mainEle.classList.add("grey-background"); + } + } + }) + .catch((error) => { + console.error("Error fetching data: ", error); + setIsLoading(false); + showNotification(`Something Went Wrong ...`, "error"); + }); + }; -export default AttendenceNotShadedCorrection \ No newline at end of file + // useEffect(() => { + // FetchAttendenceNotShadedCorrection(); + // }, []); + + useEffect(() => { + if (!reduxSystemNo) { + setShowSystemNoContainer(true); + } else { + FetchAttendenceNotShadedCorrection(reduxSystemNo); + } + }, [reduxSystemNo]); + + return ( + <> +
+ + + + {reduxSystemNo && ( + + System No : {reduxSystemNo} + + )} + + + +
+ + {AttendenceData.length > 0 && ( +
+ {AttendenceData.map((data, index) => ( +
+
+
+ Register Number : {data?.register_number} +
+
+ Subject Code : {data?.subject_code} +
+
+ Row Number : {data?.rownumber} +
+
+ S3 Path : {data?.s3_path} +
+
+ Absent Status :{" "} + {data?.absent_status || "NULL"} +
+
+ Omitted : {data?.omitted || "NULL"} +
+
+ Verified : {data?.verified} +
+
+ + + +
+
+
+ +
+
+ ))} +
+ )} +
+ {isLoading && } + {notification && ( + setNotification(null)} + /> + )} + {showSystemNoContainer && ( + + )} + + ); +}; + +export default AttendenceNotShadedCorrection; diff --git a/src/Components/HomeSections.jsx b/src/Components/HomeSections.jsx index 6c75ae2..a675ad5 100644 --- a/src/Components/HomeSections.jsx +++ b/src/Components/HomeSections.jsx @@ -59,11 +59,11 @@ const HomeSections = () => { { title:"PlayGrounds", url:`/sections/${year}/Playgrounds` + }, + { + title:"Attendence Not Shaded Solver", + url:`/sections/${year}/attendenceNotShadedCorrection` } - // }, { - // title:"Attendence Not Shaded Solver", - // url:`/sections/${year}/attendenceNotShadedCorrection` - // } // { // title:"Revaluation",