diff --git a/.env b/.env index 8c63c48..d5f5fbc 100644 --- a/.env +++ b/.env @@ -1 +1,4 @@ +# VITE_REACT_APP_BACKEND_URL="https://sandbox.exampaper.vidh.ai" VITE_REACT_APP_BACKEND_URL="http://localhost:9999" +METABASE_BASE_URL="http://metabase.usln.in/public/question/d8774923-09bb-4cd9-903b-559d417e12cf" +# VITE_REACT_APP_BACKEND_URL="https://api.exampaper.vidh.ai" \ No newline at end of file diff --git a/.gitignore b/.gitignore index a547bf3..6c92f0b 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ node_modules dist dist-ssr *.local +*.zip # Editor directories and files .vscode/* diff --git a/dist_jun11.zip b/dist_jun11.zip new file mode 100644 index 0000000..cdcb553 Binary files /dev/null and b/dist_jun11.zip differ diff --git a/dist_jun9.zip b/dist_jun9.zip new file mode 100644 index 0000000..96d33dd Binary files /dev/null and b/dist_jun9.zip differ diff --git a/package-lock.json b/package-lock.json index 363a25c..0fd7523 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,8 +18,12 @@ "react": "^18.2.0", "react-bootstrap": "^2.10.2", "react-dom": "^18.2.0", + "react-medium-image-zoom": "^5.2.4", + "react-redux": "^9.1.2", "react-router-dom": "^6.23.1", - "react-toastify": "^10.0.5" + "react-toastify": "^10.0.5", + "react-zoom-pan-pinch": "^3.4.4", + "redux": "^5.0.1" }, "devDependencies": { "@types/react": "^18.2.66", @@ -1961,6 +1965,11 @@ "@types/react": "*" } }, + "node_modules/@types/use-sync-external-store": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/@types/use-sync-external-store/-/use-sync-external-store-0.0.3.tgz", + "integrity": "sha512-EwmlvuaxPNej9+T4v5AuBPJa2x2UOJVdjCtDHgcDqitUeOtjnJKJ+apYjVcAoBEMjKW1VVFGZLUb5+qqa09XFA==" + }, "node_modules/@types/warning": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/warning/-/warning-3.0.3.tgz", @@ -5175,6 +5184,43 @@ "resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz", "integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==" }, + "node_modules/react-medium-image-zoom": { + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/react-medium-image-zoom/-/react-medium-image-zoom-5.2.4.tgz", + "integrity": "sha512-XLu/fLqpbmhiDAGA6yie78tDv4kh8GxvS7kKQArSOvCvm5zvgItoh4h01NAAvnezQ60ovsTeedHiHG3eG9CcGg==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/rpearce" + } + ], + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/react-redux": { + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.1.2.tgz", + "integrity": "sha512-0OA4dhM1W48l3uzmv6B7TXPCGmokUU4p1M44DGN2/D9a1FjVPukVjER1PcPX97jIg6aUeLq1XJo1IpfbgULn0w==", + "dependencies": { + "@types/use-sync-external-store": "^0.0.3", + "use-sync-external-store": "^1.0.0" + }, + "peerDependencies": { + "@types/react": "^18.2.25", + "react": "^18.0", + "redux": "^5.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "redux": { + "optional": true + } + } + }, "node_modules/react-refresh": { "version": "0.14.2", "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.14.2.tgz", @@ -5241,6 +5287,24 @@ "react-dom": ">=16.6.0" } }, + "node_modules/react-zoom-pan-pinch": { + "version": "3.4.4", + "resolved": "https://registry.npmjs.org/react-zoom-pan-pinch/-/react-zoom-pan-pinch-3.4.4.tgz", + "integrity": "sha512-lGTu7D9lQpYEQ6sH+NSlLA7gicgKRW8j+D/4HO1AbSV2POvKRFzdWQ8eI0r3xmOsl4dYQcY+teV6MhULeg1xBw==", + "engines": { + "node": ">=8", + "npm": ">=5" + }, + "peerDependencies": { + "react": "*", + "react-dom": "*" + } + }, + "node_modules/redux": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz", + "integrity": "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==" + }, "node_modules/reflect.getprototypeof": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.6.tgz", @@ -5874,6 +5938,14 @@ "punycode": "^2.1.0" } }, + "node_modules/use-sync-external-store": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.2.tgz", + "integrity": "sha512-PElTlVMwpblvbNqQ82d2n6RjStvdSoNe9FG28kNfz3WiXilJm4DdNkEzRhCZuIDwY8U08WVihhGR5iRqAwfDiw==", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, "node_modules/vite": { "version": "5.2.11", "resolved": "https://registry.npmjs.org/vite/-/vite-5.2.11.tgz", @@ -7312,6 +7384,11 @@ "@types/react": "*" } }, + "@types/use-sync-external-store": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/@types/use-sync-external-store/-/use-sync-external-store-0.0.3.tgz", + "integrity": "sha512-EwmlvuaxPNej9+T4v5AuBPJa2x2UOJVdjCtDHgcDqitUeOtjnJKJ+apYjVcAoBEMjKW1VVFGZLUb5+qqa09XFA==" + }, "@types/warning": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/warning/-/warning-3.0.3.tgz", @@ -9599,6 +9676,21 @@ "resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz", "integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==" }, + "react-medium-image-zoom": { + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/react-medium-image-zoom/-/react-medium-image-zoom-5.2.4.tgz", + "integrity": "sha512-XLu/fLqpbmhiDAGA6yie78tDv4kh8GxvS7kKQArSOvCvm5zvgItoh4h01NAAvnezQ60ovsTeedHiHG3eG9CcGg==", + "requires": {} + }, + "react-redux": { + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.1.2.tgz", + "integrity": "sha512-0OA4dhM1W48l3uzmv6B7TXPCGmokUU4p1M44DGN2/D9a1FjVPukVjER1PcPX97jIg6aUeLq1XJo1IpfbgULn0w==", + "requires": { + "@types/use-sync-external-store": "^0.0.3", + "use-sync-external-store": "^1.0.0" + } + }, "react-refresh": { "version": "0.14.2", "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.14.2.tgz", @@ -9641,6 +9733,17 @@ "prop-types": "^15.6.2" } }, + "react-zoom-pan-pinch": { + "version": "3.4.4", + "resolved": "https://registry.npmjs.org/react-zoom-pan-pinch/-/react-zoom-pan-pinch-3.4.4.tgz", + "integrity": "sha512-lGTu7D9lQpYEQ6sH+NSlLA7gicgKRW8j+D/4HO1AbSV2POvKRFzdWQ8eI0r3xmOsl4dYQcY+teV6MhULeg1xBw==", + "requires": {} + }, + "redux": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz", + "integrity": "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==" + }, "reflect.getprototypeof": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.6.tgz", @@ -10080,6 +10183,12 @@ "punycode": "^2.1.0" } }, + "use-sync-external-store": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.2.tgz", + "integrity": "sha512-PElTlVMwpblvbNqQ82d2n6RjStvdSoNe9FG28kNfz3WiXilJm4DdNkEzRhCZuIDwY8U08WVihhGR5iRqAwfDiw==", + "requires": {} + }, "vite": { "version": "5.2.11", "resolved": "https://registry.npmjs.org/vite/-/vite-5.2.11.tgz", diff --git a/package.json b/package.json index 3172717..614dec1 100644 --- a/package.json +++ b/package.json @@ -20,8 +20,12 @@ "react": "^18.2.0", "react-bootstrap": "^2.10.2", "react-dom": "^18.2.0", + "react-medium-image-zoom": "^5.2.4", + "react-redux": "^9.1.2", "react-router-dom": "^6.23.1", - "react-toastify": "^10.0.5" + "react-toastify": "^10.0.5", + "react-zoom-pan-pinch": "^3.4.4", + "redux": "^5.0.1" }, "devDependencies": { "@types/react": "^18.2.66", diff --git a/src/App.jsx b/src/App.jsx index 3849169..f5f2802 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -10,6 +10,8 @@ import ReassignedStats from "./Components/ReassignedStats"; import IndividualExamCentreStats from "./Components/IndividualExamCentreStats"; import PartAReassigned from "./Components/PartAReassigned"; import PartACorrection from "./Components/PartACorrection"; +import Verification from "./Components/Verification"; +import Statistics from "./Components/Statistics"; function App() { return ( @@ -36,15 +38,21 @@ function App() { element={} > - {/* } > + {/* } + > + */} + }> } > - */} + diff --git a/src/Components/AnomolyReassigned.jsx b/src/Components/AnomolyReassigned.jsx index 6b4fc5f..8fd9d1c 100644 --- a/src/Components/AnomolyReassigned.jsx +++ b/src/Components/AnomolyReassigned.jsx @@ -22,6 +22,8 @@ import HomeIcon from "@mui/icons-material/Home"; import ArrowBackIcon from "@mui/icons-material/ArrowBack"; import { useNavigate } from "react-router-dom"; import QueryStatsIcon from "@mui/icons-material/QueryStats"; +import { updateAttendenceAnomolyData } from "../redux/actions/actions"; +import { useDispatch, useSelector } from "react-redux"; const { Header, Content, Footer, Sider } = Layout; function getItem(label, key, icon, children) { @@ -32,26 +34,24 @@ function getItem(label, key, icon, children) { label, }; } -// const items = [ -// getItem('Option 1', '1', ), -// getItem('Option 2', '2', ), -// getItem('User', 'sub1', , [ -// getItem('Tom', '3'), -// getItem('Bill', '4'), -// getItem('Alex', '5'), -// ]), -// getItem('Team', 'sub2', , [getItem('Team 1', '6'), getItem('Team 2', '8')]), -// getItem('Files', '9', ), -// ]; + const items = [getItem("Reassigned Booklet No", "1", )]; const AnomolyReassigned = () => { const [collapsed, setCollapsed] = useState(false); const [anomolyData, setAnomolyData] = useState([]); + const [filteredAnomolyData,setFilterAnomolyData] = useState([]) const [tableRowData, setTableRowData] = useState([]); const [isLoading, setIsLoading] = useState(false); const [windowWidth, setWindowWidth] = useState(window.innerWidth); + const [distinctExamCentreCodes,setDistinctExamCentreCodes] = useState([]) + const dispatch = useDispatch(); + const reduxAnomolyData = useSelector((state) => state.attendenceAnomolyData); + const [filterSelectedExamCentreCode,setFilterSelectedExamCentreCode] = useState("") + + // Log Redux store state + console.log("Redux store state after dispatch:", reduxAnomolyData); useEffect(() => { const handleResize = () => { @@ -95,16 +95,41 @@ const AnomolyReassigned = () => { }; } + useEffect(()=>{ + const tmpData = []; + for (const data of anomolyData) { + tmpData.push( + createData( + data.attendence_serial_no, + data.student_slno, + data.exam_centre_code, + data.exam_centre, + data.student_name, + data.register_number, + data.reassigned_serial_no + ) + ); + } + console.log("Tmp data is : ", tmpData); + if (tmpData.length > 0) { + setTableRowData(tmpData); + } + },[anomolyData]) const fetchAnomalyData = () => { console.log("Fetching......."); setIsLoading(true); - fetch(`${import.meta.env.VITE_REACT_APP_BACKEND_URL}/fetchAnamolyAttendenceData`, { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - }) + fetch( + `${ + import.meta.env.VITE_REACT_APP_BACKEND_URL + }/fetchAnamolyAttendenceData`, + { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + } + ) .then((response) => { console.log("Response fetched.."); return response.json(); @@ -113,25 +138,24 @@ const AnomolyReassigned = () => { console.log("Response Data is : ", responseData); setIsLoading(false); if (responseData.status === "success") { - setAnomolyData(responseData.data); - const tmpData = []; - for (const data of responseData.data) { - tmpData.push( - createData( - data.attendence_serial_no, - data.student_slno, - data.exam_centre_code, - data.exam_centre, - data.student_name, - data.register_number, - data.reassigned_serial_no - ) - ); - } - console.log("Tmp data is : ", tmpData); - if (tmpData.length > 0) { - setTableRowData(tmpData); + setAnomolyData(responseData?.data); + const tmpExamCentreCodes = []; + const distinctExamCentreCodesSet = new Set(distinctExamCentreCodes); + + for (var data of responseData?.data) { + if (!distinctExamCentreCodesSet.has(data.exam_centre_code)) { + distinctExamCentreCodesSet.add(data.exam_centre_code); + tmpExamCentreCodes.push(data.exam_centre_code); + } + setFilterAnomolyData([...tmpExamCentreCodes]) } + + + setDistinctExamCentreCodes([...distinctExamCentreCodesSet]); + console.log("Tmp exam centre code: ", tmpExamCentreCodes); + + // console.log("Data to be stored in store : ", responseData?.data); + dispatch(updateAttendenceAnomolyData(responseData?.data)); } }) .catch((error) => { @@ -141,10 +165,28 @@ const AnomolyReassigned = () => { }; useEffect(() => { - fetchAnomalyData(); + if (reduxAnomolyData.length > 0) { + console.log("Redux anomoly data found") + setAnomolyData(reduxAnomolyData) + } else { + console.log("Redux anomoly data not found") + fetchAnomalyData(); + } }, []); + useEffect(()=>{ + const tmpData = [] + for(var data in anomolyData){ + if(data?.exam_centre_code == filterSelectedExamCentreCode){ + tmpData.push(data) + } + } + + },[filterSelectedExamCentreCode]) + + + const { token: { colorBgContainer, borderRadiusLG }, } = theme.useToken(); @@ -214,10 +256,18 @@ const AnomolyReassigned = () => { {tableRowData.length > 0 && ( )} + {tableRowData.length == 0 && ( + +
No Data Found !!
+
+ )}
diff --git a/src/Components/AttendenceCorrection.jsx b/src/Components/AttendenceCorrection.jsx index 2d54f95..ea961ff 100644 --- a/src/Components/AttendenceCorrection.jsx +++ b/src/Components/AttendenceCorrection.jsx @@ -17,11 +17,14 @@ import { ToastContainer, toast } from "react-toastify"; import "react-toastify/dist/ReactToastify.css"; import { useSearchParams } from "react-router-dom"; import LoadingContainer from "./LoadingContainer"; -import HomeIcon from '@mui/icons-material/Home'; -import ArrowBackIcon from '@mui/icons-material/ArrowBack'; +import HomeIcon from "@mui/icons-material/Home"; +import ArrowBackIcon from "@mui/icons-material/ArrowBack"; import { useNavigate } from "react-router-dom"; -import QueryStatsIcon from '@mui/icons-material/QueryStats'; - +import QueryStatsIcon from "@mui/icons-material/QueryStats"; +import { useDispatch, useSelector } from "react-redux"; +import { updateAttendenceAnomolyData } from "../redux/actions/actions"; +import RotateLeftIcon from "@mui/icons-material/RotateLeft"; +import RotateRightIcon from "@mui/icons-material/RotateRight"; const { Header, Content, Footer, Sider } = Layout; function getItem(label, key, icon, children) { @@ -47,6 +50,7 @@ function getItem(label, key, icon, children) { const items = [getItem("Reassigned Booklet No", "1", )]; const AttendenceCorrection = () => { + console.log("Checking1 ..."); const [collapsed, setCollapsed] = useState(false); const [bookletInput, setBookletInput] = useState(null); const [dataFetched, setDataFetched] = useState(false); @@ -54,10 +58,29 @@ const AttendenceCorrection = () => { const [updateReassigned, setUpdateReassigned] = useState(false); const [reasssingedSno, setReassignedSno] = useState(null); const [isLoading, setIsLoading] = useState(false); - const navigate = useNavigate() + const [registerNumber, setRegisterNumber] = useState(null); + const [backgroundPosition, setBackgroundPosition] = useState("0% 0%"); + const [zoomed, setZoomed] = useState(false); + const dispatch = useDispatch(); + const [scaleWidthValue, setScaleWidthValue] = useState(80); + const [rotateValue, setRotateValue] = useState(0); + + const reduxAnomolyData = useSelector((state) => state.attendenceAnomolyData); + // console.log("Anomoly Data is : ", reduxAnomolyData); + const [anomolyData, setAnomolyData] = useState([]); + + const handleMouseMove = (e) => { + const { left, top, width, height } = e.target.getBoundingClientRect(); + const x = ((e.pageX - left) / width) * 100; + const y = ((e.pageY - top) / height) * 100; + setBackgroundPosition(`${x}% ${y}%`); + setZoomed(true); + }; + + const navigate = useNavigate(); let [searchParams, setSearchParams] = useSearchParams(); const searchParamsBookletSerialNo = searchParams.get("sno"); - console.log("Serach parmas sno : ", searchParamsBookletSerialNo); + // console.log("Serach parmas sno : ", searchParamsBookletSerialNo); const [windowWidth, setWindowWidth] = useState(window.innerWidth); useEffect(() => { @@ -65,19 +88,19 @@ const AttendenceCorrection = () => { setWindowWidth(window.innerWidth); }; - window.addEventListener('resize', handleResize); + window.addEventListener("resize", handleResize); return () => { - window.removeEventListener('resize', handleResize); + window.removeEventListener("resize", handleResize); }; }, []); useEffect(() => { if (windowWidth < 800) { - setCollapsed(true) + setCollapsed(true); } - if(windowWidth > 800){ - setCollapsed(false) + if (windowWidth > 800) { + setCollapsed(false); } }, [windowWidth]); @@ -91,29 +114,68 @@ const AttendenceCorrection = () => { submitBookletInput(); }, [bookletInput]); - - const { token: { colorBgContainer, borderRadiusLG }, } = theme.useToken(); + useEffect(() => { + if (reduxAnomolyData.length === 0) { + fetchAnomalyData(); + } + }, []); + + const fetchAnomalyData = () => { + console.log("Fetching......."); + setIsLoading(true); + fetch( + `${ + import.meta.env.VITE_REACT_APP_BACKEND_URL + }/fetchAnamolyAttendenceData`, + { + 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") { + setAnomolyData(responseData?.data); + console.log("Data to be stored in store : ", responseData?.data); + dispatch(updateAttendenceAnomolyData(responseData?.data)); + } + }) + .catch((error) => { + console.error("Error fetching data: ", error); + setIsLoading(false); + }); + }; + const submitBookletInput = async () => { setIsLoading(true); setStudentData(null); if (!bookletInput) { console.log("Returning"); - return; } const payload = { bookletInput, }; - const response = await fetch(`${import.meta.env.VITE_REACT_APP_BACKEND_URL}/fetchBookletInfo`, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(payload), - }); + const response = await fetch( + `${import.meta.env.VITE_REACT_APP_BACKEND_URL}/fetchBookletInfo`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(payload), + } + ); const responseData = await response.json(); console.log("Response Data is : ", responseData); setDataFetched(true); @@ -125,26 +187,133 @@ const AttendenceCorrection = () => { } if (responseData.data) { setStudentData(responseData.data[0]); + const student_data = responseData.data[0]; + setRegisterNumber(student_data?.register_number); } } }; + const url = `https://docs.exampaper.vidh.ai/${studentData?.s3_path}`; + // console.log("Url is : ", url); + const figureStyle = { + backgroundImage: `url(${url})`, + backgroundPosition: zoomed ? backgroundPosition : "center", + backgroundSize: zoomed ? "200%" : "cover", + height: "100%", // Adjust the height as needed + width: "60%", // Adjust the width as needed + border: "1px solid #ddd", + overflow: "hidden", + }; + + const ZoomInImage = () => { + console.log("Zooming In Image ...."); + const elements = document.getElementsByClassName("scanned-img"); + for (var ele of elements) { + console.log("Ele is : ", ele); + const newScaleWidthValue = scaleWidthValue + 10; + setScaleWidthValue(newScaleWidthValue); + // ele.style.transform = `scale(${newScaleValue})`; + ele.style.width = `${newScaleWidthValue}%`; + } + }; + + const ZoomOutImage = () => { + console.log("Zooming Out Image ...."); + const elements = document.getElementsByClassName("scanned-img"); + for (var ele of elements) { + console.log("Ele is : ", ele); + const newScaleWidthValue = scaleWidthValue - 10; + setScaleWidthValue(newScaleWidthValue); + // ele.style.transform = `scale(${newScaleValue})`; + ele.style.width = `${newScaleWidthValue}%`; + } + }; + + const RotateImageLeft = () => { + const elements = document.getElementsByClassName("scanned-img"); + for (var ele of elements) { + console.log("Ele is : ", ele); + const newRotateValue = rotateValue - 90; + setRotateValue(newRotateValue); + ele.style.transform = `rotate(${newRotateValue}deg)`; + } + }; + + const RotateImageRight = () => { + const elements = document.getElementsByClassName("scanned-img"); + for (var ele of elements) { + console.log("Ele is : ", ele); + const newRotateValue = rotateValue + 90; + setRotateValue(newRotateValue); + ele.style.transform = `rotate(${newRotateValue}deg)`; + } + }; + + const ImageStyle = { + // transform: `scale(${scaleValue})`, + transformOrigin: "left", // Adjust the zoom origin as needed + transition: "transform 0.2s ease-in-out", + }; + + const containerStyle = { + width: "auto", // Set the width and height as needed + maxHeight: "90%", + overflowX: "scroll", + position: "relative", + }; + + const handleMouseLeave = () => { + setBackgroundPosition("0% 0%"); + setZoomed(false); + }; + const updateReassignedSno = async () => { + setIsLoading(true); + // if(reduxAnomolyData.length === 0){ + // console.log("Redux anomoly data length is 0.......") + // fetchAnomalyData() + // } + console.log("Reassgined Sno : ", reasssingedSno); const payload = { bookletInput, reasssingedSno, + registerNumber, }; - const response = await fetch(`${import.meta.env.VITE_REACT_APP_BACKEND_URL}/updateReassingedSno`, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(payload), - }); + const response = await fetch( + `${import.meta.env.VITE_REACT_APP_BACKEND_URL}/updateReassingedSno`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(payload), + } + ); const responseData = await response.json(); + setIsLoading(false); + setReassignedSno(null); if (responseData.status === "success" && responseData?.status_code == 200) { console.log("Updation success"); toast.success("Record Updated Successfully !!"); + var index = 0 + var RecordIndex = 0 + const filteredData = reduxAnomolyData.filter((data) => { + if (data?.student_slno === searchParamsBookletSerialNo) { + RecordIndex = index + console.log("data matched : ", data); + return false; // Return false to remove the matched item + } + index += 1 + return true; // Keep the unmatched items + }); + + console.log("Filtered Data: ", filteredData); + dispatch(updateAttendenceAnomolyData(filteredData)); + if (filteredData.length > 0) { + navigate( + `/anomoly/reassigned/booklet?sno=${filteredData[RecordIndex].student_slno}` + ); + } } else if ( responseData.status === "success" && responseData?.status_code == 405 @@ -154,6 +323,45 @@ const AttendenceCorrection = () => { } }; + const markAsAssigned = async () => { + setIsLoading(true); + const payload = { bookletInput }; + const response = await fetch( + `${import.meta.env.VITE_REACT_APP_BACKEND_URL}/markAsAssigned`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(payload), + } + ); + const responseData = await response.json(); + setIsLoading(false); + if (responseData.status === "success") { + toast.success("Record Updated Successfully !!"); + var index = 0 + var RecordIndex = 0 + const filteredData = reduxAnomolyData.filter((data) => { + if (data?.student_slno === searchParamsBookletSerialNo) { + RecordIndex = index + console.log("data matched : ", data); + return false; // Return false to remove the matched item + } + index += 1 + return true; // Keep the unmatched items + }); + + console.log("Filtered Data: ", filteredData); + dispatch(updateAttendenceAnomolyData(filteredData)); + if (filteredData.length > 0) { + navigate( + `/anomoly/reassigned/booklet?sno=${filteredData[RecordIndex].student_slno}` + ); + } + } + }; + return ( { background: colorBgContainer, }} > - + + */} - {!isLoading && !studentData && ( + {/* {!isLoading && !studentData && (
Invalid Booklet Serial No !!
- )} - {dataFetched && studentData && ( + )} */} + {studentData && ( <> -
Booklet Info:
+
+ Booklet Info: +
- - - - - - - + +
{studentData?.student_name}
- - + +
{studentData?.exam_centre_code}
+
+ + +
{studentData.exam_centre}
+
+ + +
{studentData?.exam_date}
{ setReassignedSno(e.target.value); }} /> - - + +
@@ -340,125 +542,163 @@ const AttendenceCorrection = () => { )}
- - - - - {!isLoading && !studentData && ( + {/* {!isLoading && !studentData && (
Invalid Booklet Serial No !!
- )} - {dataFetched && studentData && ( + )} */} + {studentData && ( <> -
Booklet Info:
+
+ Booklet Info: +
- - - - - - - + +
{studentData?.student_name}
- - + +
{studentData?.exam_centre_code}
+
+ + +
{studentData.exam_centre}
+
+ + +
{studentData?.exam_date}
{ setReassignedSno(e.target.value); }} /> - - + +
)}
- - {dataFetched && studentData && ( - + + {studentData && ( + <> + + + + + + + + )} - - {dataFetched && studentData && ( - + + {studentData && ( + <> + + + + + + + + )} diff --git a/src/Components/BarcodeInput.jsx b/src/Components/BarcodeInput.jsx index fbc9e4b..2986dfb 100644 --- a/src/Components/BarcodeInput.jsx +++ b/src/Components/BarcodeInput.jsx @@ -11,6 +11,7 @@ const BarcodeInput = ({setBookletInput,setDataFetched,bookletInput}) =>{ // }} // noValidate autoComplete="off" + className = "w-100" > { setBookletInput(e.target.value) diff --git a/src/Components/BookletInput.jsx b/src/Components/BookletInput.jsx index 7a0f6d2..6e36109 100644 --- a/src/Components/BookletInput.jsx +++ b/src/Components/BookletInput.jsx @@ -1,23 +1,32 @@ -import * as React from 'react'; -import Box from '@mui/material/Box'; -import TextField from '@mui/material/TextField'; +import * as React from "react"; +import Box from "@mui/material/Box"; +import TextField from "@mui/material/TextField"; -const BookletInput = ({setBookletInput,setDataFetched,bookletInput}) =>{ - return ( - :not(style)': { m: 1, width: '25ch' }, - // }} - // noValidate - autoComplete="off" - > - { - setBookletInput(e.target.value) - setDataFetched(false) - }}/> - - ); -} +const BookletInput = ({ setBookletInput, setDataFetched, bookletInput }) => { + return ( + :not(style)': { m: 1, width: '25ch' }, + // }} + // noValidate + className="w-100" + autoComplete="off" + > + { + setBookletInput(e.target.value); + setDataFetched(false); + }} + /> + + ); +}; -export default BookletInput; \ No newline at end of file +export default BookletInput; diff --git a/src/Components/Home.jsx b/src/Components/Home.jsx index c2bc3a0..f9e7866 100644 --- a/src/Components/Home.jsx +++ b/src/Components/Home.jsx @@ -1,23 +1,40 @@ import { Box } from "@mui/material"; import HomepageCard from "./HomepageCard"; - +import {useState,useEffect} from "react" const Home = () => { - // const cards = [ - // { - // title: "Reassingned Serial No Anomoly Manual Updation", - // url: "/anomoly/reassigned", - // }, - // { - // title: "Part A OCR Anomoly Manual Updation", - // url: "/anomoly/partA", - // } - // ]; const cards = [ { title: "Reassingned Serial No Anomoly Manual Updation", url: "/anomoly/reassigned", - }] + }, + // { + // title: "Part A OCR Anomoly - Batch 2022", + // url: "/anomoly/partA", + // }, + { + title: "Part A OCR Anomoly Dummy", + url: "/anomoly/partA?type=new", + }, + { + title: "Part A OCR Anomoly - Old Dummy", + url: "/anomoly/partA?type=old", + }, + // { + // title:"Verification", + // url:"/verification" + // } + { + title:"Statistics", + url:"/statistics" + } + ]; + + // const cards = [ + // { + // title: "Reassingned Serial No Anomoly Manual Updation", + // url: "/anomoly/reassigned", + // }] return ( <> diff --git a/src/Components/LoadingContainer.jsx b/src/Components/LoadingContainer.jsx index a58e298..2af8320 100644 --- a/src/Components/LoadingContainer.jsx +++ b/src/Components/LoadingContainer.jsx @@ -1,17 +1,32 @@ -import React from "react"; +import React, { useEffect } from "react"; import { Box } from "@mui/material"; import Spinner from "react-bootstrap/Spinner"; const LoadingContainer = ({ loadingText }) => { const LoadingContainerStyle = { backgroundColor: "rgba(0,0,0,0.5)", - overflow: "auto", + overflow: "hidden", + position: "fixed", + top: 0, + left: 0, + width: "100vw", + height: "100vh", + zIndex: 1000, // Ensure it appears above other content }; + useEffect(() => { + const body = document.querySelector("body"); + body.scrollTop = 0; + body.style.overflow = "hidden"; + return () => { + body.style.overflow = "auto"; + }; + }, []); + return ( <> diff --git a/src/Components/PartACorrection.jsx b/src/Components/PartACorrection.jsx index 309571f..8a01bcd 100644 --- a/src/Components/PartACorrection.jsx +++ b/src/Components/PartACorrection.jsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useState,useRef } from "react"; import { DesktopOutlined, FileOutlined, @@ -7,8 +7,6 @@ import { UserOutlined, } from "@ant-design/icons"; import { Breadcrumb, Layout, Menu, Typography, theme } from "antd"; -import BookletInput from "./BookletInput"; -import BarcodeInput from "./BarcodeInput"; import { Box, Button } from "@mui/material"; import { useEffect } from "react"; import TextField from "@mui/material/TextField"; @@ -18,11 +16,20 @@ import { ToastContainer, toast } from "react-toastify"; import "react-toastify/dist/ReactToastify.css"; import { useSearchParams } from "react-router-dom"; import LoadingContainer from "./LoadingContainer"; -import HomeIcon from '@mui/icons-material/Home'; -import ArrowBackIcon from '@mui/icons-material/ArrowBack'; +import HomeIcon from "@mui/icons-material/Home"; +import ArrowBackIcon from "@mui/icons-material/ArrowBack"; import { useNavigate } from "react-router-dom"; -import QueryStatsIcon from '@mui/icons-material/QueryStats'; - +import QueryStatsIcon from "@mui/icons-material/QueryStats"; +import RotateLeftIcon from "@mui/icons-material/RotateLeft"; +import RotateRightIcon from "@mui/icons-material/RotateRight"; +import { useSelector, useDispatch } from "react-redux"; +import { + updatePartAanomolyData, + updateSystemNo, +} from "../redux/actions/actions"; +import SimpleDialog from "./SimpleDialog"; +import SystemNumberDialog from "./SystemNumberDialog"; +import ValidationContainer from "./ValidationContainer"; const { Header, Content, Footer, Sider } = Layout; function getItem(label, key, icon, children) { @@ -49,72 +56,382 @@ const items = [getItem("Reassigned Booklet No", "1", )]; const PartACorrection = () => { const [collapsed, setCollapsed] = useState(false); - const [bookletInput, setBookletInput] = useState(null); + const [barcodeInput, setBarcodeInput] = useState(null); const [dataFetched, setDataFetched] = useState(false); const [studentData, setStudentData] = useState(null); const [updateReassigned, setUpdateReassigned] = useState(false); const [reasssingedSno, setReassignedSno] = useState(null); const [isLoading, setIsLoading] = useState(false); - const navigate = useNavigate() + const [scaleWidthValue, setScaleWidthValue] = useState(80); + const [rotateValue, setRotateValue] = useState(0); + const navigate = useNavigate(); let [searchParams, setSearchParams] = useSearchParams(); const searchParamsBarcode = searchParams.get("barcode"); - console.log("Serach parmas sno : ", searchParamsBarcode); + const batchType = searchParams.get("batchType"); + const s3Path = searchParams.get("s3Path"); const [windowWidth, setWindowWidth] = useState(window.innerWidth); + const [backgroundPosition, setBackgroundPosition] = useState("0% 0%"); + const [zoomed, setZoomed] = useState(false); + const [correctedRegisterNo, setCorrectedRegisterNo] = useState(null); + const [correctedAnswerBookletNo, setCorrectedAnswerBookletNo] = + useState(null); + const [correctedSubjectCode, setCorrectedSubjectCode] = useState(null); + const [correctedSerialNo, setCorrectedSerialNo] = useState(null); + const [correctedExamDate, setCorrectedExamDate] = useState(null); + const [correctedCandidateName, setCorrectedCandidateName] = useState(null); + const [correctedExamCentreCode, setCorrectedExamCentreCode] = useState(null); + const [correctedBarcodeNo, setCorrectedBarcodeNo] = useState(null); + const [correctedSubjectTitle, setCorrectedSubjectTitle] = useState(null); + const [showSubjectTitleInput, setShowSubjectTitleInput] = useState(false); + const [showAdditionalStudentInputs, setShowAdditionalStudentInputs] = + useState(false); + const [fallbackText, setFallBackText] = useState(null); + const [showDialogBox, setShowDialogBox] = useState(false); + const [dialogBoxConsent, setDialogBoxConsent] = useState(null); + const [dialogText, setDialogText] = useState(null); + const [metaBaseSubjectLinkWithTitle, setMetaBaseSubjectLinkWithTitle] = + useState(null); + const [metaBaseSubjectLinkWithoutTitle, setMetaBaseSubjectLinkWithoutTitle] = + useState(null); + const [metaBaseRegnoLink, setMetaBaseRegnoLink] = useState(null); + const reduxSystemNo = useSelector((state) => state?.systemNumber); + const systemNo = searchParams.get("sysNo"); + const [showSystemNoContainer, setShowSystemNoContainer] = useState(false); + const [validateContainerData, setValidateContainerData] = useState([]); + const [showValidationContainer, setShowValidationContainer] = useState(false); + + + const subjectCodeInputRef = useRef(null); + + // Handle the Enter key press in the register number input + const handleRegisterNumberKeyDown = (e) => { + if (e.key === 'Enter') { + // Focus on the subject code input + const subjectCodeInput = subjectCodeInputRef.current; + subjectCodeInput.focus(); + subjectCodeInput.select(); + } + }; + + + + const dispatch = useDispatch(); + useEffect(() => { + if (!reduxSystemNo && !systemNo) { + setShowSystemNoContainer(true); + } else { + dispatch(updateSystemNo(systemNo)); + fetchAnomalyData(); + } + }, [reduxSystemNo]); + + useEffect(() => { + if (batchType === "old") { + setShowAdditionalStudentInputs(true); + } + }, []); + + const reduxPartA2023AnomolyData = useSelector( + (state) => state.partABatchAnomolyData + ); + // console.log("Redux partA 2023 anomoly data : ",reduxPartA2023AnomolyData) + + const handleMouseMove = (e) => { + const { left, top, width, height } = e.target.getBoundingClientRect(); + const x = ((e.pageX - left) / width) * 100; + const y = ((e.pageY - top) / height) * 100; + setBackgroundPosition(`${x}% ${y}%`); + setZoomed(true); + }; useEffect(() => { const handleResize = () => { setWindowWidth(window.innerWidth); }; - window.addEventListener('resize', handleResize); + window.addEventListener("resize", handleResize); return () => { - window.removeEventListener('resize', handleResize); + window.removeEventListener("resize", handleResize); }; }, []); useEffect(() => { if (windowWidth < 800) { - setCollapsed(true) + setCollapsed(true); } - if(windowWidth > 800){ - setCollapsed(false) + if (windowWidth > 800) { + setCollapsed(false); } }, [windowWidth]); useEffect(() => { if (searchParamsBarcode) { - setBookletInput(searchParamsBarcode); + setBarcodeInput(searchParamsBarcode); } }, [searchParamsBarcode]); useEffect(() => { - submitBookletInput(); - }, [bookletInput]); + submitbarcodeInput(); + }, [barcodeInput]); + const url = `https://docs.exampaper.vidh.ai/${studentData?.s3_path}`; + const figureStyle = { + backgroundImage: `url(${url})`, + backgroundPosition: zoomed ? backgroundPosition : "center", + backgroundSize: zoomed ? "200%" : "cover", + height: "100%", // Adjust the height as needed + width: "90%", // Adjust the width as needed + border: "1px solid #ddd", + overflow: "hidden", + }; + const handleMouseLeave = () => { + setBackgroundPosition("0% 0%"); + setZoomed(false); + }; + + function getRecordsBySystemId(records, systemId) { + const new_data = []; + for (var i = 0; i < records.length; i++) { + var count = i % 5; + if (count === systemId - 1) { + new_data.push(records[i]); + } + } + return new_data; + } + + useEffect(() => { + console.log("Show additional inputs : ", showAdditionalStudentInputs); + }, [showAdditionalStudentInputs]); const { token: { colorBgContainer, borderRadiusLG }, } = theme.useToken(); - const submitBookletInput = async () => { + const validateData = () => { + setIsLoading(true); + try { + const payload = { + correctedRegisterNo, + correctedSubjectCode, + }; + fetch( + `${import.meta.env.VITE_REACT_APP_BACKEND_URL}/validateStudentData`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(payload), + } + ) + .then((response) => response.json()) + .then((responseData) => { + setIsLoading(false); + if (responseData.status === "success") { + setValidateContainerData(responseData?.data); + if ((responseData?.data).length === 0) { + setShowAdditionalStudentInputs(true); + } else { + if (batchType !== "old") { + setShowAdditionalStudentInputs(false); + } + } + setShowValidationContainer(true); + } else { + toast.error("Something Went Wrong !!"); + } + }); + } catch (error) { + throw new Error(error); + } + }; + + const fetchAnomalyData = () => { + setFallBackText(null); + console.log("Fetching......."); + setIsLoading(true); + fetch( + `${ + import.meta.env.VITE_REACT_APP_BACKEND_URL + }/fetchAnamolyPartAData?type=${batchType}`, + { + 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") { + const systemRecords = getRecordsBySystemId( + responseData?.data, + reduxSystemNo + ); + console.log("System records : ", systemRecords); + // setAnomolyData(systemRecords); + dispatch(updatePartAanomolyData(systemRecords)); + dispatch(updatePartAanomolyData(responseData?.data)); + if ((responseData?.data).length == 0) { + setFallBackText("No Data Found !!"); + } + } + }) + .catch((error) => { + console.error("Error fetching data: ", error); + setIsLoading(false); + }); + }; + + useEffect(() => { + // console.log("12345 Useeffect called"); + console.log("Consent is : ", dialogBoxConsent); + // console.log("Dialog text before if condition :: ",dialogText) + // console.log("showDialog Box : ",showDialogBox) + if (dialogBoxConsent == "No" && !showDialogBox) { + console.log("Consent is NO"); + var index = 0; + var RecordIndex = 0; + var localStoragePartAanomoly = []; + if (batchType === "old") { + localStoragePartAanomoly = localStorage.getItem("part-a-old-anomoly"); + console.log( + "localstorage parta anomoly : ", + JSON.parse(localStoragePartAanomoly) + ); + if (localStoragePartAanomoly) { + localStoragePartAanomoly = JSON.parse(localStoragePartAanomoly); + } + } else if (batchType !== "old") { + localStoragePartAanomoly = localStorage.getItem("part-a-anomoly"); + console.log( + "localstorage parta anomoly : ", + JSON.parse(localStoragePartAanomoly) + ); + if (localStoragePartAanomoly) { + localStoragePartAanomoly = JSON.parse(localStoragePartAanomoly); + } + } + console.log( + "Length of redux data >>>>>>>>>>>>>>>>>>>>> ", + localStoragePartAanomoly.length + ); + const filteredData = localStoragePartAanomoly.filter((data) => { + console.log("S3path : ", s3Path); + if (data?.s3_path == s3Path) { + RecordIndex = index; + console.log("data matched : ", data); + return false; // Return false to remove the matched item + } + index += 1; + return true; // Keep the unmatched items + }); + console.log("RecordIndex is : ", RecordIndex); + console.log("Lenght of filtered Data >>>>>>>>>>> ", filteredData.length); + console.log("Filtered Data Part A: ", filteredData); + dispatch(updatePartAanomolyData(filteredData)); + if (batchType === "old") { + localStorage.setItem( + "part-a-old-anomoly", + JSON.stringify(filteredData) + ); + } else if (batchType !== "old") { + localStorage.setItem("part-a-anomoly", JSON.stringify(filteredData)); + } + if (filteredData.length > 0) { + console.log("navigating ...", filteredData[RecordIndex].s3_path); + setDialogBoxConsent(null); + const navigationLink = `/anomoly/partA/booklet?batchType=${batchType}&barcode=${filteredData[RecordIndex].barcode}&s3Path=${filteredData[RecordIndex].s3_path}&sysNo=${reduxSystemNo}`; + console.log("Navigation link123 : ", navigationLink); + // navigate(navigationLink); + window.location.href = navigationLink; + } else { + toast.success("All Records Are Updated ...."); + navigate("/"); + } + } else if (dialogBoxConsent == "Yes" && !showDialogBox) { + if (dialogText) { + const lowerCaseDialogText = dialogText.toLowerCase(); + console.log("Lower case dialog text :: ", lowerCaseDialogText); + if ( + lowerCaseDialogText.includes("registration") && + !lowerCaseDialogText.includes("subject") + ) { + console.log("Register number not found"); + setShowAdditionalStudentInputs(true); + setMetaBaseRegnoLink( + "https://metabase.usln.in/public/question/8f4aaf13-7cee-4378-bfb7-1635b6ae8265" + ); + } else if ( + lowerCaseDialogText.includes("registration") && + lowerCaseDialogText.includes("subject") + ) { + setShowSubjectTitleInput(true); + setShowAdditionalStudentInputs(true); + console.log("Both register number and subject code not found"); + setMetaBaseSubjectLinkWithTitle( + "https://metabase.usln.in/public/question/65dee651-0b18-4f07-b992-48b07d74f2c9" + ); + setMetaBaseSubjectLinkWithoutTitle( + "https://metabase.usln.in/public/question/3175d0f2-b292-42ec-a72f-41382d442879" + ); + setMetaBaseRegnoLink( + "https://metabase.usln.in/public/question/8f4aaf13-7cee-4378-bfb7-1635b6ae8265" + ); + } else if ( + lowerCaseDialogText.includes("subject") && + !lowerCaseDialogText.includes("registration") + ) { + setShowSubjectTitleInput(true); + console.log("Subject Code not found"); + setMetaBaseSubjectLinkWithTitle( + "https://metabase.usln.in/public/question/65dee651-0b18-4f07-b992-48b07d74f2c9" + ); + setMetaBaseSubjectLinkWithoutTitle( + "https://metabase.usln.in/public/question/3175d0f2-b292-42ec-a72f-41382d442879" + ); + } + } + const container = document.getElementById("iframe-container"); + if (container) { + console.log("Container found"); + setTimeout(function () { + console.log("Scrolling...."); + container.scrollIntoView(); + }, 1000); // 2000 milliseconds = 2 seconds + } + } + }, [dialogBoxConsent, setDialogBoxConsent, showDialogBox]); + + const submitbarcodeInput = async () => { setIsLoading(true); setStudentData(null); - if (!bookletInput) { + if (!barcodeInput) { console.log("Returning"); return; } const payload = { - bookletInput, + barcodeInput, + s3Path, }; - const response = await fetch(`${import.meta.env.VITE_REACT_APP_BACKEND_URL}/fetchBarcodeInfo`, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(payload), - }); + const response = await fetch( + `${import.meta.env.VITE_REACT_APP_BACKEND_URL}/fetchBarcodeInfo`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(payload), + } + ); const responseData = await response.json(); console.log("Response Data is : ", responseData); setDataFetched(true); @@ -125,37 +442,186 @@ const PartACorrection = () => { setStudentData(null); } if (responseData.data) { - console.log("Students Data :",responseData.data[0]) + console.log("Students Data :", responseData.data[0]); setStudentData(responseData.data[0]); + const students_data = responseData.data[0]; + setCorrectedRegisterNo(students_data?.register_number); + setCorrectedSubjectCode(students_data?.subject_code); + setCorrectedSerialNo(students_data?.slno); } } + if (reduxPartA2023AnomolyData.length == 0) { + fetchAnomalyData(); + } }; - const updateReassignedSno = async () => { + const updatePartAanomoly = async (e) => { + setIsLoading(true); + setMetaBaseRegnoLink(null); + setMetaBaseSubjectLinkWithTitle(null); + setMetaBaseSubjectLinkWithoutTitle(null); + const s3_path = studentData?.s3_path; const payload = { - bookletInput, - reasssingedSno, + batchType, + s3_path, + barcodeInput, + correctedRegisterNo, + correctedSubjectCode, + correctedBarcodeNo, + correctedCandidateName, + correctedExamDate, + correctedSerialNo, + correctedExamCentreCode, + correctedSubjectTitle, }; - const response = await fetch(`${import.meta.env.VITE_REACT_APP_BACKEND_URL}/updateReassingedSno`, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(payload), - }); + const response = await fetch( + `${import.meta.env.VITE_REACT_APP_BACKEND_URL}/updatePartAanomoly`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(payload), + } + ); const responseData = await response.json(); - if (responseData.status === "success" && responseData?.status_code == 200) { - console.log("Updation success"); - toast.success("Record Updated Successfully !!"); - } else if ( - responseData.status === "success" && - responseData?.status_code == 405 + setIsLoading(false); + if ( + responseData?.status === "success" && + responseData?.status_code == 200 ) { - console.log("Updation not allowed"); - toast.error("Reassigned Serial No is Invalid !!"); + toast.success(responseData?.message); + var index = 0; + var RecordIndex = 0; + console.log( + "length of redux data >>>>>>>>>>>>>> ", + reduxPartA2023AnomolyData.length + ); + var localStoragePartAanomoly = []; + if (batchType === "old") { + localStoragePartAanomoly = localStorage.getItem("part-a-old-anomoly"); + console.log( + "localstorage parta anomoly : ", + JSON.parse(localStoragePartAanomoly) + ); + if (localStoragePartAanomoly) { + localStoragePartAanomoly = JSON.parse(localStoragePartAanomoly); + } + } else if (batchType !== "old") { + localStoragePartAanomoly = localStorage.getItem("part-a-anomoly"); + console.log( + "localstorage parta anomoly : ", + JSON.parse(localStoragePartAanomoly) + ); + if (localStoragePartAanomoly) { + localStoragePartAanomoly = JSON.parse(localStoragePartAanomoly); + } + } + const filteredData = localStoragePartAanomoly.filter((data) => { + console.log("S3path : ", s3Path); + if (data?.s3_path == s3Path) { + RecordIndex = index; + console.log("data matched : ", data); + return false; // Return false to remove the matched item + } + index += 1; + return true; // Keep the unmatched items + }); + console.log("Record Index is : ", RecordIndex); + console.log("Filtered Data Part A: ", filteredData); + console.log( + "Filtered array length >>>>>>>>>>>>>>>>>>>> ", + filteredData.length + ); + dispatch(updatePartAanomolyData(filteredData)); + if (batchType === "old") { + localStorage.setItem( + "part-a-old-anomoly", + JSON.stringify(filteredData) + ); + } else if (batchType !== "old") { + localStorage.setItem("part-a-anomoly", JSON.stringify(filteredData)); + } + if (filteredData.length > 0) { + console.log("navigating ...", filteredData[RecordIndex].s3_path); + setDialogBoxConsent(null); + const navigationLink = `/anomoly/partA/booklet?batchType=${batchType}&barcode=${filteredData[RecordIndex].barcode}&s3Path=${filteredData[RecordIndex].s3_path}&sysNo=${reduxSystemNo}`; + console.log("Navigation link123 : ", navigationLink); + // navigate(navigationLink); + window.location.href = navigationLink; + } else { + toast.success("All Records Are Updated ...."); + navigate("/"); + } + } else if (responseData?.status_code == 500) { + toast.error("Something Went Wrong !!"); + } else if ( + responseData?.status === "success" && + responseData?.status_code == 205 + ) { + setShowDialogBox(true); + + setDialogText(responseData?.missing_data); } }; + const ZoomInImage = () => { + console.log("Zooming In Image ...."); + const elements = document.getElementsByClassName("scanned-img"); + for (var ele of elements) { + console.log("Ele is : ", ele); + const newScaleWidthValue = scaleWidthValue + 10; + setScaleWidthValue(newScaleWidthValue); + // ele.style.transform = `scale(${newScaleValue})`; + ele.style.width = `${newScaleWidthValue}%`; + } + }; + + const ZoomOutImage = () => { + console.log("Zooming Out Image ...."); + const elements = document.getElementsByClassName("scanned-img"); + for (var ele of elements) { + console.log("Ele is : ", ele); + const newScaleWidthValue = scaleWidthValue - 10; + setScaleWidthValue(newScaleWidthValue); + // ele.style.transform = `scale(${newScaleValue})`; + ele.style.width = `${newScaleWidthValue}%`; + } + }; + + const RotateImageLeft = () => { + const elements = document.getElementsByClassName("scanned-img"); + for (var ele of elements) { + console.log("Ele is : ", ele); + const newRotateValue = rotateValue - 90; + setRotateValue(newRotateValue); + ele.style.transform = `rotate(${newRotateValue}deg)`; + } + }; + + const RotateImageRight = () => { + const elements = document.getElementsByClassName("scanned-img"); + for (var ele of elements) { + console.log("Ele is : ", ele); + const newRotateValue = rotateValue + 90; + setRotateValue(newRotateValue); + ele.style.transform = `rotate(${newRotateValue}deg)`; + } + }; + + const handleKeyDown = (event) => { + console.log("Handling key down ..."); + if (event.key === "Enter") { + console.log("Enter pressed ..."); + updatePartAanomoly(event); + } + }; + + const handleSystemNoChange = () => { + console.log("System No Change is called"); + setShowSystemNoContainer(true); + }; + return ( { background: colorBgContainer, }} > - + {fallbackText &&

{fallbackText}

} + {showDialogBox && ( + + )} + - - {/* */} - + + {reduxSystemNo && ( + + System No : {reduxSystemNo} + + )} + + + - {/* Reassigned Booklet Serial Manual Updation : */} - {/* - User - Bill - */} - {/*
- Bill is a cat. -
*/} - - - + + +
{barcodeInput}
{!isLoading && !studentData && ( @@ -260,78 +713,200 @@ const PartACorrection = () => { {dataFetched && studentData && ( <> - -
Barcode Info:
-
- + {batchType != "old" && ( + + +
+ {studentData?.booklet_serial_no} +
+
+ )} - - - - - - - + +
+ {studentData?.subject_code} +
- {/* - - - */} - + { + <> + {/* + + + { + setCorrectedBarcodeNo(e.target.value); + }} + /> + + */} + {showSubjectTitleInput && ( + + + + { + correctedSubjectTitle(e.target.value); + }} + /> + + + )} + {showAdditionalStudentInputs && ( + <> + + + + { + setCorrectedExamCentreCode( + e.target.value + ); + }} + /> + + + + + + { + setCorrectedExamDate(e.target.value); + }} + placeholder="(DD-MM-YYYY)" + /> + + + + + + { + setCorrectedCandidateName(e.target.value); + }} + /> + + + {batchType === "old" && ( + + + + { + setCorrectedSerialNo(e.target.value); + }} + /> + + + )} + + )} + + } + + { - setReassignedSno(e.target.value); + setCorrectedRegisterNo(e.target.value); }} /> - - + + + + { + // if(correctedRegisterNo && correctedSubjectCode){ + // validateData() + // } + // }} + autoComplete="off" + onKeyDown={handleKeyDown} + inputRef={subjectCodeInputRef} + onChange={(e) => { + setCorrectedSubjectCode(e.target.value); + }} + /> + + + + @@ -342,19 +917,11 @@ const PartACorrection = () => { )} - - - + + +
{barcodeInput}
{!isLoading && !studentData && ( @@ -364,78 +931,181 @@ const PartACorrection = () => { {dataFetched && studentData && ( <> - -
Barcode Info:
-
- - - - - - - - + +
+ {studentData?.subject_code} +
- {/* - - - */} - + { + <> + {/* + + + { + setCorrectedBarcodeNo(e.target.value); + }} + /> + + */} + {showSubjectTitleInput && ( + + + + { + correctedSubjectTitle(e.target.value); + }} + /> + + + )} + {showAdditionalStudentInputs && ( + <> + + + + { + setCorrectedExamCentreCode( + e.target.value + ); + }} + /> + + + + + + { + setCorrectedExamDate(e.target.value); + }} + placeholder="(DD-MM-YYYY)" + /> + + + + + + { + setCorrectedCandidateName(e.target.value); + }} + /> + + + + + + { + setCorrectedSerialNo(e.target.value); + }} + /> + + + + )} + + } + + { - setReassignedSno(e.target.value); + setCorrectedRegisterNo(e.target.value); }} /> - - + + + + { + setCorrectedSubjectCode(e.target.value); + }} + /> + + + + @@ -445,22 +1115,147 @@ const PartACorrection = () => { )} - - {dataFetched && studentData && ( - + + {studentData && ( + + + + + + + )} + {studentData && ( + <> + + + + + {metaBaseSubjectLinkWithTitle && ( + +