part-a fixes in palyground

This commit is contained in:
yokesh22 2024-07-24 14:31:16 +05:30
parent d247442c8f
commit c06b37b28d
2 changed files with 57 additions and 56 deletions

View File

@ -53,8 +53,9 @@ const UpdatedPlaygroundUpdater = ({
const [totalStudents, setTotalStudents] = useState(null); const [totalStudents, setTotalStudents] = useState(null);
const [totalPresent, setTotalPresent] = useState(null); const [totalPresent, setTotalPresent] = useState(null);
const [totalAbsent, setTotalAbsent] = useState(null); const [totalAbsent, setTotalAbsent] = useState(null);
const [barcode, setBarcode] = useState(null); // const [barcode, setBarcode] = useState(null);
const [qrcode, setQrcode] = useState(null); const [qrcode, setQrcode] = useState(null);
const [bar_code, set_Barcode] = useState(null);
const [s3Path, setS3Path] = useState(null); const [s3Path, setS3Path] = useState(null);
const [subjectCode, setSubjectCode] = useState(null); const [subjectCode, setSubjectCode] = useState(null);
const [data,setData] = useState(null) const [data,setData] = useState(null)
@ -67,62 +68,26 @@ const UpdatedPlaygroundUpdater = ({
useEffect(() => { useEffect(() => {
console.log("data ========== ", data); console.log("data ========== ", data);
if (data) { if (data) {
console.log("barcode = ", data.barcode)
setQrcode(data.qrcode); setQrcode(data.qrcode);
setBarcode(data.barcode); // set_Barcode(data.barcode)
set_Barcode(data.barcode === '' ? null : data.barcode);
setMarks(data.marks); setMarks(data.marks);
setS3Path(data.s3Path); setS3Path(data.s3_path);
setSubjectCode(data.subject_code); setSubjectCode(data.subject_code);
setRegisterNumber(data.register_number); setRegisterNumber(data.register_number);
setTotalAbsent(data?.total_absent); setTotalAbsent(data?.total_absent);
setTotalPresent(data?.total_present); setTotalPresent(data?.total_present);
setTotalStudents(data?.total_students); setTotalStudents(data?.total_students);
setRotateAngle(0);
} }
console.log("the currect editor type: ", type); console.log("the currect editor type: ", type);
}, [data]); }, [data]);
useEffect(() => { // useEffect(() => {
console.log("barcode in use effect ==== ", barcode); // console.log("barcode in use effect ==== ", barcode);
}, [barcode]); // }, [barcode]);
const updateRecordPartC = async () => {
if (!marks) {
return;
}
setIsLoading(true);
try {
const payload = {
qrcode,
barcode,
table: tableName,
s3Path,
subjectCode,
marks,
imageName,
rotateAngle,
};
const response = await fetch(
`${import.meta.env.VITE_REACT_APP_BACKEND_URL}/editPartCdata`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
}
);
const responseData = await response.json();
setIsLoading(false);
console.log("response data ========= ", responseData);
if (responseData?.status === "success") {
//toast.success("Record Updated Successfully ...");
setShowEditContainer(false);
}
} catch (error) {
setIsLoading(false);
//toast.error("Something Went Wrong ...");
throw new Error(error);
}
};
console.log("data =================== ", data); console.log("data =================== ", data);
// console.log("image column ====== ", s3_image_column); // console.log("image column ====== ", s3_image_column);
@ -440,16 +405,16 @@ const UpdatedPlaygroundUpdater = ({
const updateRecordPartA = async () => { const updateRecordPartA = async () => {
console.log(registerNumber); console.log(registerNumber);
console.log(subjectCode); console.log(subjectCode);
console.log(barcode, qrcode); console.log(bar_code, qrcode);
console.log(!registerNumber && !subjectCode && (!barcode || !qrcode)); console.log(!registerNumber && !subjectCode && (!bar_code || !qrcode));
if (!registerNumber && !subjectCode && (!barcode || !qrcode)) { if (!registerNumber && !subjectCode && (!bar_code || !qrcode)) {
return; return;
} }
setIsLoading(true); setIsLoading(true);
try { try {
const payload = { const payload = {
qrcode, qrcode,
barcode, bar_code,
table: tableName, table: tableName,
s3Path, s3Path,
subjectCode, subjectCode,
@ -618,13 +583,14 @@ const UpdatedPlaygroundUpdater = ({
<Box className="border border-dark" id={imageName}> <Box className="border border-dark" id={imageName}>
<img <img
src={`https://docs.exampaper.vidh.ai/${oldData[s3_image_column]}`} src={`https://docs.exampaper.vidh.ai/${oldData[s3_image_column]}`}
width="1200px" width="850px"
height="auto" height="auto"
alt="Image Alt" alt="Image Alt"
ref={imageEleRef} ref={imageEleRef}
/> />
</Box> </Box>
</Box> </Box>
{/* <Box {/* <Box
className="d-flex flex-column gap-2 mx-2 py-3" className="d-flex flex-column gap-2 mx-2 py-3"
style={{ minWidth: "250px" }} style={{ minWidth: "250px" }}
@ -674,17 +640,17 @@ const UpdatedPlaygroundUpdater = ({
{type !== "Attendence" ? ( {type !== "Attendence" ? (
<> <>
<TextInputField <TextInputField
value={qrcode} value={qrcode || ''}
setValue={setQrcode} setValue={setQrcode}
placeholder={"QR code"} placeholder={"QR code"}
/> />
<TextInputField <TextInputField
value={barcode | null} value={bar_code || ''}
setValue={setBarcode} setValue={set_Barcode}
placeholder={"BarCode"} placeholder={"BarCode"}
/> />
<TextInputField <TextInputField
value={subjectCode} value={subjectCode || ''}
setValue={setSubjectCode} setValue={setSubjectCode}
placeholder={"Subject code"} placeholder={"Subject code"}
/> />
@ -726,11 +692,43 @@ const UpdatedPlaygroundUpdater = ({
/> />
) : type == "PartA" ? ( ) : type == "PartA" ? (
<TextInputField <TextInputField
value={registerNumber} value={registerNumber || ''}
setValue={setRegisterNumber} setValue={setRegisterNumber}
placeholder={"Register no"} placeholder={"Register no"}
/> />
) : null} ) : null}
<Box display="flex" justifyContent="space-between">
<Button
className="m-0 bg-primary text-white p-3 rounded"
onClick={rotateLeft}
>
Rotate left
<RotateLeftIcon />
</Button>
<Button
className="m-0 bg-primary text-white p-3 rounded"
onClick={rotateRight}
>
Rotate Right
<RotateRightIcon />
</Button>
</Box>
{/* <Button
className="m-0 bg-primary text-white p-3 rounded"
onClick={() =>
saveRotatedImage(
imageName,
tableNameData,
rotateAngle,
data,
setIsLoading
)
}
>
Save
</Button> */}
{type == "PartC" ? ( {type == "PartC" ? (
<Button <Button
className="bg-primary text-white p-3" className="bg-primary text-white p-3"
@ -765,6 +763,9 @@ const UpdatedPlaygroundUpdater = ({
</Button> </Button>
) : null} ) : null}
{/* <Button className="bg-primary text-white p-3">Skip</Button> */} {/* <Button className="bg-primary text-white p-3">Skip</Button> */}
<Box className="d-flex justify-content-between gap-5"> <Box className="d-flex justify-content-between gap-5">
<Button <Button
className="bg-primary text-white p-3 w-50" className="bg-primary text-white p-3 w-50"