This commit is contained in:
Pradeeppon01 2024-07-14 22:47:11 +05:30
parent 24e413f6cf
commit 8701ee0fd4
6 changed files with 283 additions and 69 deletions

View File

@ -188,7 +188,7 @@ useEffect(()=>{
<Box className="my-3">
<Button
className="p-3 bg-primary text-light rounded"
onClick={reinitializeScanner}
onClick={()=>window.location.reload()}
>
Scan Again
</Button>

View File

@ -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));

View File

@ -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 () => {
@ -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;
}
@ -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 (
<Dialog open={open} sx={{ zIndex: 'fab' }} onClose={handleClose} maxWidth="xl" style={{zIndex:100}} fullWidth>
<Dialog
open={open}
sx={{ zIndex: "fab" }}
onClose={handleClose}
maxWidth="xl"
style={{ zIndex: 100 }}
fullWidth
>
<DialogContent>
<Box className="d-flex justify-content-between align-items-start gap-4">
<Box className="d-flex flex-column">
<Box className="d-flex flex-column" style={imageStyle}>
<img
src={`https://docs.exampaper.vidh.ai/${s3Path}`}
height={"100%"}
@ -149,6 +164,8 @@ const PlayGroundEditContainer = ({
/>
</Box>
<Box className="py-3 d-flex flex-column justify-content-end w-100 gap-3">
{type !== "Attendence" ? (
<>
<TextInputField
value={qrcode}
setValue={setQrcode}
@ -164,38 +181,82 @@ const PlayGroundEditContainer = ({
setValue={setSubjectCode}
placeholder={"Subject code"}
/>
{
type == 'PartC'?(
</>
) : (
<>
<TextInputField
value={qrcode}
setValue={setQrcode}
placeholder={"QR code"}
/>
<TextInputField
value={subjectCode}
setValue={setSubjectCode}
placeholder={"Subject Code"}
/>
<TextInputField
value={totalStudents}
setValue={setTotalStudents}
placeholder={"Total Students"}
/>
<TextInputField
value={totalPresent}
setValue={setTotalPresent}
placeholder={"Total Present"}
/>
<TextInputField
value={totalAbsent}
setValue={setTotalAbsent}
placeholder={"Total Absent"}
/>
</>
)}
{type == "PartC" ? (
<TextInputField
value={marks}
setValue={setMarks}
placeholder={"Marks"}
/>
): type == 'PartA'?(
) : type == "PartA" ? (
<TextInputField
value={registerNumber}
setValue={setRegisterNumber}
placeholder={"Register no"}
/>
):null
}
{
type == 'PartC'?(
) : null}
{type == "PartC" ? (
<Button
className="bg-primary text-white p-3"
onClick={() => updateRecordPartC()}
>
Update
</Button>
): type == 'PartA'?(
) : type == "PartA" ? (
<Button
className="bg-primary text-white p-3"
onClick={() => updateRecordPartA()}
>
Update
</Button>
):null
) : type == "Attendence" ? (
<Button
className="bg-primary text-white p-3"
onClick={() =>
updatePlayGroundAttendence(
setIsLoading,
qrcode,
subjectCode,
totalStudents,
totalPresent,
totalAbsent,
data,
setShowEditContainer
)
}
>
Update
</Button>
) : null}
<Button
className="bg-primary text-white p-3"
onClick={() => setShowEditContainer(false)}

View File

@ -12,10 +12,10 @@ const PlayGrounds = () => {
title: "PART - C",
url: "/Playground/PartC",
},
// {
// title: "ATTENDENCE",
// url: "/Playground/Attendence",
// },
{
title: "ATTENDENCE",
url: "/Playground/Attendence",
},
];
return (
<>

View File

@ -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);
}
};