From 8701ee0fd4ecace32f3ef29ea5873a942c0ad99f Mon Sep 17 00:00:00 2001 From: Pradeeppon01 Date: Sun, 14 Jul 2024 22:47:11 +0530 Subject: [PATCH] latest --- .env | 2 +- src/Components/BarcodeScanner.jsx | 2 +- src/Components/CustomQueryExecutorCard.jsx | 15 ++ src/Components/PlayGroundEditContainer.jsx | 187 ++++++++++++------ src/Components/PlayGrounds.jsx | 8 +- .../AttendencePlaygroundUtilities.jsx | 138 +++++++++++++ 6 files changed, 283 insertions(+), 69 deletions(-) create mode 100644 src/Components/Utilities/AttendencePlaygroundUtilities.jsx diff --git a/.env b/.env index 43b1052..a596950 100644 --- a/.env +++ b/.env @@ -1,5 +1,5 @@ #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="http://localhost:9999" VITE_REACT_APP_BACKEND_URL="https://api.exampaper.vidh.ai" \ No newline at end of file diff --git a/src/Components/BarcodeScanner.jsx b/src/Components/BarcodeScanner.jsx index f90a041..84f1283 100644 --- a/src/Components/BarcodeScanner.jsx +++ b/src/Components/BarcodeScanner.jsx @@ -188,7 +188,7 @@ useEffect(()=>{ diff --git a/src/Components/CustomQueryExecutorCard.jsx b/src/Components/CustomQueryExecutorCard.jsx index 0f4d295..875b639 100644 --- a/src/Components/CustomQueryExecutorCard.jsx +++ b/src/Components/CustomQueryExecutorCard.jsx @@ -12,6 +12,8 @@ import RotateRightIcon from "@mui/icons-material/RotateRight"; import PlayGroundEditContainer from "./PlayGroundEditContainer"; import saveRotatedImage from "./Utilities/PartCPlaygroundUtilities"; import markAsPartc from "./Utilities/PartAPlaygroundUtilities"; +import { updateAttendenceBlank } from "./Utilities/AttendencePlaygroundUtilities"; + const CustomQueryExecutorCard = ({ @@ -289,6 +291,11 @@ const CustomQueryExecutorCard = ({ // setEditorType(type) }; + + const updateAttendenceBlankAction = () =>{ + updateAttendenceBlank(setIsLoading,data,setShowEditContainer) + } + const buttonActions = { PartC: [ { btnLabel: "Mark As Front", action: updateFront }, @@ -305,8 +312,16 @@ const CustomQueryExecutorCard = ({ { btnLabel: "Mark As Part-C", action: markAsPartc }, { btnLabel: "Edit", action: showContainerAction }, ], + Attendence: [ + { btnLabel: "Mark As Blank", action:updateAttendenceBlankAction }, + { btnLabel: "Edit", action: showContainerAction }, + ] }; + + + + useEffect(() => { setDataValue(data); setKeys(Object.keys(data)); diff --git a/src/Components/PlayGroundEditContainer.jsx b/src/Components/PlayGroundEditContainer.jsx index 8a3b192..9c7dbdd 100644 --- a/src/Components/PlayGroundEditContainer.jsx +++ b/src/Components/PlayGroundEditContainer.jsx @@ -10,7 +10,10 @@ import TextInputField from "./TextInputField"; import { Height } from "@mui/icons-material"; import HighlightOffIcon from "@mui/icons-material/HighlightOff"; import LoadingContainer from "./LoadingContainer"; -import {toast} from "react-toastify" +import { toast } from "react-toastify"; +import { updatePlayGroundAttendence } from "./Utilities/AttendencePlaygroundUtilities"; +import { updateAttendenceBlank } from "./Utilities/AttendencePlaygroundUtilities"; + const PlayGroundEditContainer = ({ data, @@ -19,13 +22,16 @@ const PlayGroundEditContainer = ({ tableName, setShowEditContainer, rotateAngle, - type + type, }) => { // const type = "PartC"; // const type = type; const dialogText = "This is dialog text"; const [marks, setMarks] = useState(null); const [registerNumber, setRegisterNumber] = useState(null); + const [totalStudents, setTotalStudents] = useState(null); + const [totalPresent, setTotalPresent] = useState(null); + const [totalAbsent, setTotalAbsent] = useState(null); const [barcode, setBarcode] = useState(null); const [isLoading, setIsLoading] = useState(false); const [qrcode, setQrcode] = useState(null); @@ -40,10 +46,13 @@ const PlayGroundEditContainer = ({ setQrcode(data?.qrcode); setBarcode(data?.barcode); setMarks(data?.marks); - setSubjectCode(data?.subject_code) - setRegisterNumber(data?.register_number) + setSubjectCode(data?.subject_code); + setRegisterNumber(data?.register_number); + setTotalAbsent(data?.total_absent) + setTotalPresent(data?.total_present) + setTotalStudents(data?.total_students) } - console.log("the currect editor type: ", type) + console.log("the currect editor type: ", type); }, [data]); const updateRecordPartC = async () => { @@ -55,7 +64,7 @@ const PlayGroundEditContainer = ({ const payload = { qrcode, barcode, - table:tableName, + table: tableName, s3Path, subjectCode, marks, @@ -77,7 +86,7 @@ const PlayGroundEditContainer = ({ console.log("response data ========= ", responseData); if (responseData?.status === "success") { toast.success("Record Updated Successfully ..."); - setShowEditContainer(false) + setShowEditContainer(false); } } catch (error) { setIsLoading(false); @@ -86,12 +95,11 @@ const PlayGroundEditContainer = ({ } }; - const updateRecordPartA = async () => { - console.log(registerNumber) - console.log(subjectCode) - console.log(barcode, qrcode) - console.log(!registerNumber && !subjectCode && (!barcode || !qrcode)) + console.log(registerNumber); + console.log(subjectCode); + console.log(barcode, qrcode); + console.log(!registerNumber && !subjectCode && (!barcode || !qrcode)); if (!registerNumber && !subjectCode && (!barcode || !qrcode)) { return; } @@ -100,7 +108,7 @@ const PlayGroundEditContainer = ({ const payload = { qrcode, barcode, - table:tableName, + table: tableName, s3Path, subjectCode, registerNumber, @@ -122,7 +130,7 @@ const PlayGroundEditContainer = ({ console.log("response data ========= ", responseData); if (responseData?.status === "success") { toast.success("Record Updated Successfully ..."); - setShowEditContainer(false) + setShowEditContainer(false); } } catch (error) { setIsLoading(false); @@ -132,16 +140,23 @@ const PlayGroundEditContainer = ({ }; const imageStyle = { - transform:`rotate(${rotateAngle})deg` - } + transform: `rotate(${rotateAngle})deg !important`, + }; - console.log("Image style ====== ",imageStyle) + console.log("Image style ====== ", imageStyle); return ( - + - + - - - - { - type == 'PartC'?( + {type !== "Attendence" ? ( + <> - ): type == 'PartA'?( - ):null - } - { - type == 'PartC'?( - - ): type == 'PartA'?( - - ):null - } + + + ) : ( + <> + + + + + + + )} + {type == "PartC" ? ( + + ) : type == "PartA" ? ( + + ) : null} + {type == "PartC" ? ( + + ) : type == "PartA" ? ( + + ) : type == "Attendence" ? ( + + ) : null} ); }; diff --git a/src/Components/PlayGrounds.jsx b/src/Components/PlayGrounds.jsx index 854e856..a81b173 100644 --- a/src/Components/PlayGrounds.jsx +++ b/src/Components/PlayGrounds.jsx @@ -12,10 +12,10 @@ const PlayGrounds = () => { title: "PART - C", url: "/Playground/PartC", }, - // { - // title: "ATTENDENCE", - // url: "/Playground/Attendence", - // }, + { + title: "ATTENDENCE", + url: "/Playground/Attendence", + }, ]; return ( <> diff --git a/src/Components/Utilities/AttendencePlaygroundUtilities.jsx b/src/Components/Utilities/AttendencePlaygroundUtilities.jsx new file mode 100644 index 0000000..bfc693b --- /dev/null +++ b/src/Components/Utilities/AttendencePlaygroundUtilities.jsx @@ -0,0 +1,138 @@ +import { toast } from "react-toastify"; + +const saveRotatedImage = async ( + imageName, + tableNameData, + rotateAngle, + data, + setIsLoading +) => { + try { + console.log("data=", data); + if (rotateAngle === 0) { + return; + } + const payload = { + imageName, + tableNameData, + rotateAngle, + s3_path: data["s3_path"], + }; + setIsLoading(true); + const response = await fetch( + `${import.meta.env.VITE_REACT_APP_BACKEND_URL}/saveRotatedImage`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(payload), + } + ); + setIsLoading(false); + const responseData = await response.json(); + if (responseData.status === "success") { + toast.success("Image Rotation Saved Successfully"); + } + } catch (error) { + setIsLoading(false); + throw new Error(error); + } +}; + +export default saveRotatedImage; + +export const updatePlayGroundAttendence = async ( + setIsLoading, + qrcode, + subjectCode, + totalStudents, + totalPresent, + totalAbsent, + data, + setShowEditContainer +) => { + try { + console.log("qrcode ==== ", qrcode); + console.log("subject code ==== ", subjectCode); + console.log("total students ==== ", totalStudents); + console.log("total Absent ==== ", totalAbsent); + console.log("total preent ==== ", totalPresent); + + if (!subjectCode || !String(totalStudents) || !String(totalAbsent) || !String(totalPresent)) { + toast.info("Please fill all the fields ..."); + return; + } + console.log("updating attendence ..."); + console.log("Data ==== ", data); + setIsLoading(true); + const payload = { + qrcode, + subjectCode, + totalStudents, + totalPresent, + totalAbsent, + data, + }; + const response = await fetch( + `${ + import.meta.env.VITE_REACT_APP_BACKEND_URL + }/updatePlaygroundAttendence`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(payload), + } + ); + setIsLoading(false); + const responseData = await response.json(); + if (responseData.status === "success") { + toast.success("Attendence Updation Successfully"); + setShowEditContainer(false); + }else{ + toast.error("Something went Wrong !!") + } + } catch (error) { + setIsLoading(false); + toast.error("Something went Wrong !!"); + throw new Error(error); + } +}; + +export const updateAttendenceBlank = async ( + setIsLoading, + data, + setShowEditContainer +) => { + try { + console.log("Data ==== ", data); + setIsLoading(true); + const payload = { + data, + }; + const response = await fetch( + `${import.meta.env.VITE_REACT_APP_BACKEND_URL}/updateAttendenceBlank`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(payload), + } + ); + setIsLoading(false); + const responseData = await response.json(); + if (responseData.status === "success") { + toast.success("Attendence Marked as blank Successfully"); + setShowEditContainer(false); + } else { + toast.error("Something went Wrong !!"); + } + } catch (error) { + setIsLoading(false); + toast.error("Something went Wrong !!"); + throw new Error(error); + } +};