import * as React from "react"; import { styled } from "@mui/system"; import { TablePagination, tablePaginationClasses as classes, } from "@mui/base/TablePagination"; import { Link } from "react-router-dom"; import TextField from "@mui/material/TextField"; import { Box } from "@mui/material"; import InputLabel from "@mui/material/InputLabel"; import MenuItem from "@mui/material/MenuItem"; import FormControl from "@mui/material/FormControl"; import Select from "@mui/material/Select"; import Backdrop from '@mui/material/Backdrop'; import CircularProgress from '@mui/material/CircularProgress'; import ImageDialog from "./ImageDialog"; import { Button } from "bootstrap"; export default function TableComponentAdditionalSheet({ filterSelectedExamCentreCode, setFilterSelectedExamCentreCode, rows, type, distinctExamCentreCodes, batchType, }) { // console.log("Exam centre code in table component : ",distinctExamCentreCodes) console.log("Rows in table component : ", rows); // console.log("Type is : ", type); const [page, setPage] = React.useState(0); const [rowsPerPage, setRowsPerPage] = React.useState(5); const [isDialogOpen, setIsDialogOpen] = React.useState(false); const [currentImagePath, setCurrentImagePath] = React.useState(''); const [openLoader, setOpenLoader] = React.useState(false); const handleCloseLoader = () => { setOpenLoader(false); }; const handleOpenLoader = () => { setOpenLoader(true); }; // Avoid a layout jump when reaching the last page with empty rows. const emptyRows = page > 0 ? Math.max(0, (1 + page) * rowsPerPage - rows.length) : 0; const handleChangePage = (event, newPage) => { setPage(newPage); }; const handleChangeRowsPerPage = (event) => { setRowsPerPage(parseInt(event.target.value, 10)); setPage(0); }; const handleFilterExamCentreCode = (e) => { const ExamCentreCode = e.target.value; setFilterSelectedExamCentreCode(ExamCentreCode); }; const handleImageClick = (imagePath) => { console.log("imagepath:",imagePath) setCurrentImagePath(imagePath); setIsDialogOpen(true) }; const handleCloseDialog = () => { setIsDialogOpen(false); setCurrentImagePath(''); }; const [file, setFile] = React.useState(null); const [csvData, setCsvData] = React.useState([]); const handleFileChange = (event) => { setFile(event.target.files[0]); console.log("event.target.files[0]: ",event.target.files[0]) }; const handleFileUpload = async () => { if (!file) { alert('Please upload a CSV file first.'); return; } handleOpenLoader() const formData = new FormData(); formData.append('file', file); try { const response = await fetch( `${ import.meta.env.VITE_REACT_APP_BACKEND_URL }/uploadAdditionalAttendanceCsv`, { method: "POST", body: formData } ) if (response.ok) { const data = await response.json(); console.log('File uploaded successfully:', data); handleCloseLoader() } else { console.error('File upload failed:', response.statusText); handleCloseLoader() } } catch (error) { console.error('Error uploading file:', error); handleCloseLoader() } }; const parseCSV = (text) => { const rows = text.split('\n'); const data = rows.map(row => row.split(',')); setCsvData(data); }; return ( {type === "AnomolyReassigned" && ( <>
Manual Verification Needed Students :
{/* Exam Centre Code */} {(rowsPerPage > 0 ? rows.slice( page * rowsPerPage, page * rowsPerPage + rowsPerPage ) : rows ).map((row) => ( {/* */} ))} {emptyRows > 0 && ( )}
Attendance Image
{row.attendence_serial_no} {/* {row.answer_booklet_sno} */} {row.exam_centre_code} {row.exam_centre} {row.student_name} {row.register_number} {row.s3_path}
)} {type === "ReassignedStats" && ( <>
Exam Centre Code Complete MetaData :
{(rowsPerPage > 0 ? rows.slice( page * rowsPerPage, page * rowsPerPage + rowsPerPage ) : rows ).map((row) => ( ))} {emptyRows > 0 && ( )}
Exam Centre Code Total Scanned Count Manual Verification Count
{row.exam_centre_code} {row.total_count} {row.manual_verification_count}
)} {type === "IndividualReassignedStats" && ( <>
Exam Centre Code-Date Wise MetaData :
{(rowsPerPage > 0 ? rows.slice( page * rowsPerPage, page * rowsPerPage + rowsPerPage ) : rows ).map((row) => ( ))} {emptyRows > 0 && ( )}
Exam Centre Code Exam Date Subject Code Total Count Manual Verification Count
{row.exam_centre_code} {row.exam_date} {row.subject_code} {row.total_count} {row.manual_verification_needed_count}
)} {type === "PartAReassigned" && ( <>
Part-A Anomoly Data :
{(rowsPerPage > 0 ? rows.slice( page * rowsPerPage, page * rowsPerPage + rowsPerPage ) : rows ).map((row) => ( ))} {emptyRows > 0 && ( )}
s3_path Barcode Subject Code Register Number Type
{row?.s3_path} {row.barcode} {row.subject_code} {row.register_number} {row.type}
)} {type === "AttendenceAdditionalRecord" && ( <>
Part-A Anomoly Data :
{(rowsPerPage > 0 ? rows.slice( page * rowsPerPage, page * rowsPerPage + rowsPerPage ) : rows ).map((row) => ( ))} {emptyRows > 0 && ( )}
qrcode Cover A Cover B Subject Code Total Students Total Present Total Absent
{row?.qrcode} {row.coverA} {row.coverB} {row.subject_code} {row.total_students} {row.total_present} {row.total_absent}
)} {type === "AdditionalSheet" && ( <>
Attendance Additional Sheet
Download Template CSV

Please download the CSV file and by verifying the image type appropriately

{(rowsPerPage > 0 ? rows.slice( page * rowsPerPage, page * rowsPerPage + rowsPerPage ) : rows ).map((row) => ( {/* */} ))} {emptyRows > 0 && ( )}
Image Name upload csv Image
{row.image_name}
handleImageClick(row.s3_image_path)}> Preview Image
{row?.s3_image_path}
)} { isDialogOpen && ( ) } theme.zIndex.drawer + 1 }} open={openLoader} >
); } const grey = { 50: "#F3F6F9", 100: "#E5EAF2", 200: "#DAE2ED", 300: "#C7D0DD", 400: "#B0B8C4", 500: "#9DA8B7", 600: "#6B7A90", 700: "#434D5B", 800: "#303740", 900: "#1C2025", }; const Root = styled("div")( ({ theme }) => ` table { font-family: 'IBM Plex Sans', sans-serif; font-size: 0.875rem; border-collapse: collapse; width: 100%; } td, th { border: 1px solid ${theme.palette.mode === "dark" ? grey[800] : grey[200]}; text-align: left; padding: 8px; } th { background-color: ${theme.palette.mode === "dark" ? grey[900] : "#fff"}; } ` ); const CustomTablePagination = styled(TablePagination)` & .${classes.toolbar} { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; @media (min-width: 768px) { flex-direction: row; align-items: center; } } & .${classes.selectLabel} { margin: 0; } & .${classes.displayedRows} { margin: 0; @media (min-width: 768px) { margin-left: auto; } } & .${classes.spacer} { display: none; } & .${classes.actions} { display: flex; gap: 0.25rem; } `;