2024-07-06 20:24:25 +05:30
|
|
|
import { Box, Button } from "@mui/material";
|
|
|
|
|
import DownloadIcon from "@mui/icons-material/Download";
|
|
|
|
|
import { LazyLoadImage } from "react-lazy-load-image-component";
|
|
|
|
|
import { Label, MoreHorizTwoTone, RotateRight } from "@mui/icons-material";
|
2024-07-10 23:25:34 +05:30
|
|
|
import { useState, useEffect, useRef } from "react";
|
2024-07-14 08:58:24 +05:30
|
|
|
import { ToastContainer, toast } from "react-toastify";
|
2024-07-06 20:24:25 +05:30
|
|
|
import LoadingContainer from "./LoadingContainer";
|
|
|
|
|
import { useNavigate } from "react-router-dom";
|
2024-07-10 23:25:34 +05:30
|
|
|
// import "react-toastify/dist/ReactToastify.css";
|
|
|
|
|
import RotateLeftIcon from "@mui/icons-material/RotateLeft";
|
|
|
|
|
import RotateRightIcon from "@mui/icons-material/RotateRight";
|
2024-07-14 08:58:24 +05:30
|
|
|
import PlayGroundEditContainer from "./PlayGroundEditContainer";
|
|
|
|
|
import saveRotatedImage from "./Utilities/PartCPlaygroundUtilities";
|
2024-07-12 17:54:43 +05:30
|
|
|
import markAsPartc from "./Utilities/PartAPlaygroundUtilities";
|
2024-07-14 22:47:11 +05:30
|
|
|
import { updateAttendenceBlank } from "./Utilities/AttendencePlaygroundUtilities";
|
|
|
|
|
|
2024-07-06 20:24:25 +05:30
|
|
|
|
2024-07-14 08:58:24 +05:30
|
|
|
|
2024-07-06 20:24:25 +05:30
|
|
|
const CustomQueryExecutorCard = ({
|
|
|
|
|
data,
|
|
|
|
|
s3_image_column,
|
|
|
|
|
query,
|
|
|
|
|
error,
|
|
|
|
|
error_reason,
|
|
|
|
|
reduxSystemNo,
|
|
|
|
|
degreeType,
|
|
|
|
|
type,
|
2024-07-10 23:25:34 +05:30
|
|
|
tableName,
|
2024-11-30 18:43:01 +05:30
|
|
|
year
|
2024-07-06 20:24:25 +05:30
|
|
|
}) => {
|
|
|
|
|
// console.log("ERROR ============= ",error)
|
|
|
|
|
// console.log("ERROR REASON ============== ",error_reason)
|
|
|
|
|
// console.log("REDUX SYSTEM NO ================== ",reduxSystemNo)
|
|
|
|
|
const navigate = useNavigate();
|
2024-11-30 18:43:01 +05:30
|
|
|
console.log("year in custom query executer card ====== ",year)
|
|
|
|
|
const imageDomain = (year === "april2024" ? "https://docs.exampaper.vidh.ai" : (year === "november2024" ? 'https://images.exampaper.usln.in' : 'https://docs.exampaper.vidh.ai'))
|
|
|
|
|
console.log('imageDomain ===== ',imageDomain)
|
2024-07-06 20:24:25 +05:30
|
|
|
const [dataValue, setDataValue] = useState({});
|
|
|
|
|
const [isLoading, setIsLoading] = useState(false);
|
|
|
|
|
// console.log("data in query executor Card : ", data);
|
|
|
|
|
const [keys, setKeys] = useState([]);
|
|
|
|
|
const [values, setValues] = useState([]);
|
|
|
|
|
const [rotateAngle, setRotateAngle] = useState(0);
|
2024-07-10 23:25:34 +05:30
|
|
|
const [imageName, setImageName] = useState(null);
|
|
|
|
|
const [tableNameData, setTableNameData] = useState(null);
|
|
|
|
|
const imageEleRef = useRef();
|
2024-07-14 08:58:24 +05:30
|
|
|
const [showEditContainer, setShowEditContainer] = useState(false);
|
2024-07-12 17:54:43 +05:30
|
|
|
const [editorType, setEditorType] = useState(null);
|
|
|
|
|
|
2024-07-10 23:25:34 +05:30
|
|
|
console.log("data =================== ", data);
|
2024-07-06 20:24:25 +05:30
|
|
|
// console.log("image column ====== ", s3_image_column);
|
|
|
|
|
// console.log("s3 image ======= ", data[s3_image_column]);
|
|
|
|
|
// console.log("Keys ==== ",keys)
|
|
|
|
|
// console.log("Values ===== ",values)
|
|
|
|
|
|
2024-07-10 23:25:34 +05:30
|
|
|
useEffect(() => {
|
|
|
|
|
if (data) {
|
|
|
|
|
console.log("Image name ====== ", data?.image_name);
|
|
|
|
|
setImageName(data?.image_name);
|
2024-07-06 20:24:25 +05:30
|
|
|
}
|
2024-07-10 23:25:34 +05:30
|
|
|
if (tableName) {
|
|
|
|
|
setTableNameData(tableName);
|
2024-07-06 20:24:25 +05:30
|
|
|
}
|
2024-07-14 08:58:24 +05:30
|
|
|
if (data?.subject_code) {
|
2024-07-11 18:25:52 +05:30
|
|
|
}
|
2024-07-10 23:25:34 +05:30
|
|
|
}, [data]);
|
2024-07-06 20:24:25 +05:30
|
|
|
|
2024-07-10 23:25:34 +05:30
|
|
|
const updatePartAInstructions = async () => {
|
|
|
|
|
console.log("update instrunction");
|
|
|
|
|
const payload = {
|
|
|
|
|
data,
|
|
|
|
|
};
|
|
|
|
|
try {
|
|
|
|
|
setIsLoading(true);
|
|
|
|
|
const response = await fetch(
|
|
|
|
|
`${import.meta.env.VITE_REACT_APP_BACKEND_URL}/updatePartAInstructions`,
|
|
|
|
|
{
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(payload),
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
setIsLoading(false);
|
|
|
|
|
const responseData = await response.json();
|
|
|
|
|
if (responseData.status === "success") {
|
|
|
|
|
console.log("Updation successfull ....");
|
|
|
|
|
const updatedData = { ...dataValue, is_backpage: 1 };
|
|
|
|
|
// console.log("Data ===== ", updatedData);
|
2024-07-16 18:26:22 +05:30
|
|
|
setDataValue(updatedData);
|
|
|
|
|
// toast.success("Record Marked as Backpage ! ....");
|
|
|
|
|
} else {
|
|
|
|
|
throw new Error(responseData?.message);
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
throw new Error(error);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const markAsPartc = async () => {
|
|
|
|
|
console.log("update markAsPartc");
|
|
|
|
|
const payload = {
|
|
|
|
|
data,
|
|
|
|
|
};
|
|
|
|
|
try {
|
|
|
|
|
setIsLoading(true);
|
|
|
|
|
const response = await fetch(
|
|
|
|
|
`${import.meta.env.VITE_REACT_APP_BACKEND_URL}/markAsPartc`,
|
|
|
|
|
{
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(payload),
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
setIsLoading(false);
|
|
|
|
|
const responseData = await response.json();
|
|
|
|
|
if (responseData.status === "success") {
|
|
|
|
|
console.log("Updation successfull ....");
|
|
|
|
|
const updatedData = { ...dataValue, is_backpage: 1 };
|
|
|
|
|
// console.log("Data ===== ", updatedData);
|
2024-07-10 23:25:34 +05:30
|
|
|
setDataValue(updatedData);
|
|
|
|
|
// toast.success("Record Marked as Backpage ! ....");
|
|
|
|
|
} else {
|
|
|
|
|
throw new Error(responseData?.message);
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
throw new Error(error);
|
|
|
|
|
}
|
2024-07-06 20:24:25 +05:30
|
|
|
};
|
|
|
|
|
|
2024-07-10 23:25:34 +05:30
|
|
|
const updatePartAFront = async () => {
|
|
|
|
|
console.log("update front");
|
|
|
|
|
const payload = {
|
|
|
|
|
data,
|
|
|
|
|
};
|
|
|
|
|
try {
|
|
|
|
|
setIsLoading(true);
|
|
|
|
|
const response = await fetch(
|
|
|
|
|
`${import.meta.env.VITE_REACT_APP_BACKEND_URL}/partAFrontSideMarking`,
|
|
|
|
|
{
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(payload),
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
setIsLoading(false);
|
|
|
|
|
const responseData = await response.json();
|
|
|
|
|
if (responseData.status === "success") {
|
|
|
|
|
console.log("Updation successfull ....");
|
|
|
|
|
const updatedData = { ...dataValue, is_backpage: 1 };
|
|
|
|
|
// console.log("Data ===== ", updatedData);
|
|
|
|
|
setDataValue(updatedData);
|
|
|
|
|
// toast.success("Record Marked as Backpage ! ....");
|
|
|
|
|
} else {
|
|
|
|
|
throw new Error(responseData?.message);
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
throw new Error(error);
|
|
|
|
|
}
|
2024-07-06 20:24:25 +05:30
|
|
|
};
|
|
|
|
|
|
2024-07-10 23:25:34 +05:30
|
|
|
const updateFront = async () => {
|
|
|
|
|
console.log("update front");
|
2024-07-06 20:24:25 +05:30
|
|
|
const payload = {
|
|
|
|
|
data,
|
2024-11-30 18:43:01 +05:30
|
|
|
year
|
2024-07-06 20:24:25 +05:30
|
|
|
};
|
|
|
|
|
try {
|
|
|
|
|
setIsLoading(true);
|
|
|
|
|
const response = await fetch(
|
2024-07-10 23:25:34 +05:30
|
|
|
`${import.meta.env.VITE_REACT_APP_BACKEND_URL}/partcEvFrontSideMarking`,
|
2024-07-06 20:24:25 +05:30
|
|
|
{
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(payload),
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
setIsLoading(false);
|
|
|
|
|
const responseData = await response.json();
|
|
|
|
|
if (responseData.status === "success") {
|
2024-07-10 23:25:34 +05:30
|
|
|
console.log("Updation successfull ....");
|
|
|
|
|
const updatedData = { ...dataValue, is_backpage: 1 };
|
2024-07-06 20:24:25 +05:30
|
|
|
// console.log("Data ===== ", updatedData);
|
|
|
|
|
setDataValue(updatedData);
|
2024-07-16 17:50:16 +05:30
|
|
|
// toast.success("Record Marked as Frontpage ! ....");
|
2024-07-06 20:24:25 +05:30
|
|
|
} else {
|
2024-07-14 08:58:24 +05:30
|
|
|
toast.error("Something Went Wrong !...");
|
|
|
|
|
setIsLoading(false)
|
2024-07-06 20:24:25 +05:30
|
|
|
throw new Error(responseData?.message);
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
throw new Error(error);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2024-07-10 23:25:34 +05:30
|
|
|
const updateBack = async () => {
|
2024-07-06 20:24:25 +05:30
|
|
|
const payload = {
|
|
|
|
|
data,
|
2024-11-30 18:43:01 +05:30
|
|
|
year
|
2024-07-06 20:24:25 +05:30
|
|
|
};
|
|
|
|
|
try {
|
|
|
|
|
setIsLoading(true);
|
|
|
|
|
const response = await fetch(
|
2024-07-10 23:25:34 +05:30
|
|
|
`${import.meta.env.VITE_REACT_APP_BACKEND_URL}/partcEvBacksideMarking`,
|
2024-07-06 20:24:25 +05:30
|
|
|
{
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(payload),
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
setIsLoading(false);
|
|
|
|
|
const responseData = await response.json();
|
|
|
|
|
if (responseData.status === "success") {
|
|
|
|
|
console.log("Updation successfull ....");
|
2024-07-10 23:25:34 +05:30
|
|
|
const updatedData = { ...dataValue, is_backpage: 1 };
|
2024-07-06 20:24:25 +05:30
|
|
|
// console.log("Data ===== ", updatedData);
|
|
|
|
|
setDataValue(updatedData);
|
2024-07-16 17:50:16 +05:30
|
|
|
// toast.success("Record Marked as Backpage ! ....");
|
2024-07-06 20:24:25 +05:30
|
|
|
} else {
|
2024-07-14 08:58:24 +05:30
|
|
|
setIsLoading(false);
|
|
|
|
|
toast.error("Something Went Wrong !...");
|
2024-07-06 20:24:25 +05:30
|
|
|
throw new Error(responseData?.message);
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
throw new Error(error);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2024-07-10 23:25:34 +05:30
|
|
|
const initateProcess = () => {
|
|
|
|
|
console.log("inititate process..");
|
|
|
|
|
};
|
2024-07-06 20:24:25 +05:30
|
|
|
|
2024-07-10 23:25:34 +05:30
|
|
|
const rotateLeft = () => {
|
|
|
|
|
console.log("rotate left .....");
|
|
|
|
|
const newAngle = rotateAngle - 90;
|
|
|
|
|
setRotateAngle((prev) => prev - 90);
|
|
|
|
|
console.log("new angle ....", newAngle);
|
|
|
|
|
const newStyle = `rotate(${newAngle}deg)`;
|
|
|
|
|
imageEleRef.current.style.transform = newStyle;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const rotateRight = () => {
|
|
|
|
|
console.log("rotate right");
|
|
|
|
|
const newAngle = rotateAngle + 90;
|
|
|
|
|
setRotateAngle((prev) => prev + 90);
|
|
|
|
|
const newStyle = `rotate(${newAngle}deg)`;
|
|
|
|
|
imageEleRef.current.style.transform = newStyle;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const updateEvCover = async () => {
|
|
|
|
|
const payload = {
|
|
|
|
|
data,
|
2024-11-30 18:43:01 +05:30
|
|
|
year
|
2024-07-10 23:25:34 +05:30
|
|
|
};
|
|
|
|
|
try {
|
2024-07-06 20:24:25 +05:30
|
|
|
setIsLoading(true);
|
|
|
|
|
const response = await fetch(
|
2024-07-10 23:25:34 +05:30
|
|
|
`${import.meta.env.VITE_REACT_APP_BACKEND_URL}/partcEvCoverMarking`,
|
2024-07-06 20:24:25 +05:30
|
|
|
{
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(payload),
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
setIsLoading(false);
|
|
|
|
|
const responseData = await response.json();
|
|
|
|
|
if (responseData.status === "success") {
|
2024-07-10 23:25:34 +05:30
|
|
|
const updatedData = { ...dataValue, is_cover: 1 };
|
|
|
|
|
// console.log("Data ===== ", updatedData);
|
|
|
|
|
setDataValue(updatedData);
|
|
|
|
|
console.log("Updation successfull ....");
|
|
|
|
|
// toast.success("Record Marked As Ev !...");
|
|
|
|
|
} else {
|
|
|
|
|
throw new Error(responseData?.message);
|
2024-07-06 20:24:25 +05:30
|
|
|
}
|
2024-07-10 23:25:34 +05:30
|
|
|
} catch (error) {
|
|
|
|
|
throw new Error(error);
|
2024-07-06 20:24:25 +05:30
|
|
|
}
|
2024-07-10 23:25:34 +05:30
|
|
|
};
|
2024-07-06 20:24:25 +05:30
|
|
|
|
2024-07-19 18:15:40 +05:30
|
|
|
const markAsPart_A = async () => {
|
|
|
|
|
const payload = {
|
|
|
|
|
data,
|
2024-11-30 18:43:01 +05:30
|
|
|
year
|
2024-07-19 18:15:40 +05:30
|
|
|
};
|
|
|
|
|
try {
|
|
|
|
|
setIsLoading(true);
|
|
|
|
|
const response = await fetch(
|
|
|
|
|
`${import.meta.env.VITE_REACT_APP_BACKEND_URL}/markAsPartA`,
|
|
|
|
|
{
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(payload),
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
setIsLoading(false);
|
|
|
|
|
const responseData = await response.json();
|
|
|
|
|
if (responseData.status === "success") {
|
|
|
|
|
const updatedData = { ...dataValue, is_cover: 1 };
|
|
|
|
|
// console.log("Data ===== ", updatedData);
|
|
|
|
|
setDataValue(updatedData);
|
|
|
|
|
console.log("Updation successfull ....");
|
|
|
|
|
// toast.success("Record Marked As Ev !...");
|
|
|
|
|
} else {
|
|
|
|
|
throw new Error(responseData?.message);
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
throw new Error(error);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2024-07-14 08:58:24 +05:30
|
|
|
const markAsDummy = async () => {
|
2024-07-06 20:24:25 +05:30
|
|
|
const payload = {
|
|
|
|
|
data,
|
2024-11-30 18:43:01 +05:30
|
|
|
year
|
2024-07-06 20:24:25 +05:30
|
|
|
};
|
|
|
|
|
try {
|
|
|
|
|
setIsLoading(true);
|
|
|
|
|
const response = await fetch(
|
2024-07-10 23:25:34 +05:30
|
|
|
`${import.meta.env.VITE_REACT_APP_BACKEND_URL}/partcEvDummyMarking`,
|
2024-07-06 20:24:25 +05:30
|
|
|
{
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(payload),
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
setIsLoading(false);
|
|
|
|
|
const responseData = await response.json();
|
|
|
|
|
if (responseData.status === "success") {
|
2024-07-10 23:25:34 +05:30
|
|
|
const updatedData = { ...dataValue, is_cover: 1 };
|
2024-07-06 20:24:25 +05:30
|
|
|
// console.log("Data ===== ", updatedData);
|
|
|
|
|
setDataValue(updatedData);
|
2024-07-10 23:25:34 +05:30
|
|
|
console.log("Updation successfull ....");
|
2024-07-16 17:50:16 +05:30
|
|
|
// toast.success("Record Marked As Ev !...");
|
2024-07-06 20:24:25 +05:30
|
|
|
} else {
|
2024-07-14 08:58:24 +05:30
|
|
|
setIsLoading(false)
|
|
|
|
|
toast.error("Something Went Wrong !...");
|
2024-07-06 20:24:25 +05:30
|
|
|
throw new Error(responseData?.message);
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
2024-07-14 08:58:24 +05:30
|
|
|
setIsLoading(false);
|
|
|
|
|
toast.error("Something Went Wrong !...");
|
2024-07-10 23:25:34 +05:30
|
|
|
throw new Error(error);
|
|
|
|
|
}
|
2024-07-14 08:58:24 +05:30
|
|
|
};
|
2024-07-10 23:25:34 +05:30
|
|
|
|
2024-07-14 08:58:24 +05:30
|
|
|
const showContainerAction = () => {
|
|
|
|
|
setShowEditContainer(true);
|
|
|
|
|
console.log("type === ", type);
|
2024-07-12 17:54:43 +05:30
|
|
|
// setEditorType(type)
|
2024-07-14 08:58:24 +05:30
|
|
|
};
|
2024-07-10 23:25:34 +05:30
|
|
|
|
2024-07-14 22:47:11 +05:30
|
|
|
|
|
|
|
|
const updateAttendenceBlankAction = () =>{
|
|
|
|
|
updateAttendenceBlank(setIsLoading,data,setShowEditContainer)
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-10 23:25:34 +05:30
|
|
|
const buttonActions = {
|
|
|
|
|
PartC: [
|
|
|
|
|
{ btnLabel: "Mark As Front", action: updateFront },
|
|
|
|
|
{ btnLabel: "Mark As Back", action: updateBack },
|
|
|
|
|
{ btnLabel: "Mark As Ev", action: updateEvCover },
|
2024-07-14 08:58:24 +05:30
|
|
|
{ btnLabel: "Mark As Dummy", action: markAsDummy },
|
2024-07-19 18:15:40 +05:30
|
|
|
{btnLabel: "Mark As Part-A", action: markAsPart_A},
|
2024-07-14 08:58:24 +05:30
|
|
|
{ btnLabel: "Edit", action: showContainerAction },
|
2024-07-10 23:25:34 +05:30
|
|
|
],
|
|
|
|
|
PartA: [
|
|
|
|
|
{ btnLabel: "Mark As Front", action: updatePartAFront },
|
2024-07-12 17:54:43 +05:30
|
|
|
{ btnLabel: "Mark As Backpage", action: updatePartAInstructions },
|
|
|
|
|
// { btnLabel: "Initiate Process", action: initateProcess },
|
2024-07-14 08:58:24 +05:30
|
|
|
{ btnLabel: "Mark As Dummy", action: markAsDummy },
|
|
|
|
|
{ btnLabel: "Mark As Part-C", action: markAsPartc },
|
|
|
|
|
{ btnLabel: "Edit", action: showContainerAction },
|
2024-07-10 23:25:34 +05:30
|
|
|
],
|
2024-07-14 22:47:11 +05:30
|
|
|
Attendence: [
|
|
|
|
|
{ btnLabel: "Mark As Blank", action:updateAttendenceBlankAction },
|
|
|
|
|
{ btnLabel: "Edit", action: showContainerAction },
|
|
|
|
|
]
|
2024-07-10 23:25:34 +05:30
|
|
|
};
|
|
|
|
|
|
2024-07-14 22:47:11 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-10 23:25:34 +05:30
|
|
|
useEffect(() => {
|
|
|
|
|
setDataValue(data);
|
|
|
|
|
setKeys(Object.keys(data));
|
|
|
|
|
setValues(Object.values(data));
|
|
|
|
|
}, [data]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
console.log("Data value ===== ", dataValue);
|
|
|
|
|
setKeys(Object.keys(dataValue));
|
|
|
|
|
setValues(Object.values(dataValue));
|
|
|
|
|
}, [dataValue]);
|
|
|
|
|
|
2024-07-06 20:24:25 +05:30
|
|
|
const rotate_and_process = async () => {
|
|
|
|
|
setIsLoading(true);
|
|
|
|
|
try {
|
|
|
|
|
const payload = {
|
|
|
|
|
data,
|
|
|
|
|
};
|
|
|
|
|
const response = await fetch(
|
|
|
|
|
`${import.meta.env.VITE_REACT_APP_BACKEND_URL}/partCRotateProcess`,
|
|
|
|
|
{
|
|
|
|
|
method: "POST",
|
|
|
|
|
header: {
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(payload),
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
const responseData = await response.json();
|
|
|
|
|
setIsLoading(false);
|
|
|
|
|
if (responseData.status === "success") {
|
|
|
|
|
console.log("Response successfull ...");
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
setIsLoading(false);
|
2024-07-12 17:58:01 +05:30
|
|
|
throw new Error(error);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2024-07-14 08:58:24 +05:30
|
|
|
const saveRotatedImage = async () => {
|
2024-07-12 17:58:01 +05:30
|
|
|
try {
|
|
|
|
|
if (rotateAngle === 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const payload = {
|
|
|
|
|
imageName,
|
|
|
|
|
tableNameData,
|
|
|
|
|
rotateAngle,
|
|
|
|
|
s3_path: data[s3_image_column],
|
|
|
|
|
};
|
|
|
|
|
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") {
|
2024-07-14 08:58:24 +05:30
|
|
|
toast.success("Image Rotation Saved Successfully");
|
|
|
|
|
} else {
|
|
|
|
|
toast.error("Something Went Wrong !...");
|
2024-07-12 17:58:01 +05:30
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
setIsLoading(false);
|
2024-07-14 08:58:24 +05:30
|
|
|
toast.error("Something Went Wrong !...");
|
2024-07-06 20:24:25 +05:30
|
|
|
throw new Error(error);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
2024-08-07 02:10:38 +05:30
|
|
|
<Box className="w-100 rounded shadow mb-5 white-background" id={imageName}>
|
2024-07-14 08:58:24 +05:30
|
|
|
<ToastContainer/>
|
2024-07-06 20:24:25 +05:30
|
|
|
<Box className="p-4 d-flex justify-content-between align-items-start">
|
|
|
|
|
<Box className="p-1">
|
|
|
|
|
<Box className="p-2 d-flex justify-content-end gap-3 align-items-center">
|
|
|
|
|
{/* {query.includes("ocr_scanned_part_c_v1") &&
|
|
|
|
|
data[s3_image_column] && (
|
|
|
|
|
<>
|
|
|
|
|
<Button
|
|
|
|
|
className="w-50 m-0 bg-primary text-white p-1 rounded"
|
|
|
|
|
onClick={() => navigate(`/sqlPlayground/edit?image_name=${data["image_name"]}&table=ocr_scanned_part_c_v1&error=${error}&error_reason=${error_reason}&sysNo=${reduxSystemNo}°reeType=${degreeType}`)}
|
|
|
|
|
>
|
|
|
|
|
Edit
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
className="w-50 m-0 bg-primary text-white p-1 rounded"
|
|
|
|
|
onClick={() => {
|
|
|
|
|
mark_as_backpage();
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Mark As Back
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
className="w-50 m-0 bg-primary text-white p-1 rounded"
|
|
|
|
|
onClick={() => {
|
|
|
|
|
mark_as_ev();
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Mark As EV
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
className="w-50 m-0 bg-primary text-white p-1 rounded"
|
|
|
|
|
onClick={() => {
|
|
|
|
|
mark_as_dummy();
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Mark As Dummy
|
|
|
|
|
</Button>
|
|
|
|
|
</>
|
|
|
|
|
)} */}
|
2024-07-10 23:25:34 +05:30
|
|
|
|
|
|
|
|
{/* <Button className="bg-primary">
|
2024-07-06 20:24:25 +05:30
|
|
|
<a
|
|
|
|
|
href={`https://docs.exampaper.vidh.ai/${data[s3_image_column]}`}
|
|
|
|
|
>
|
|
|
|
|
<DownloadIcon className="text-light text-white" />
|
|
|
|
|
</a>
|
2024-07-10 23:25:34 +05:30
|
|
|
</Button> */}
|
2024-07-06 20:24:25 +05:30
|
|
|
</Box>
|
|
|
|
|
<Box className="border border-dark" id={imageName}>
|
|
|
|
|
<img
|
2024-11-30 18:43:01 +05:30
|
|
|
src={`${imageDomain}/${data[s3_image_column]}`}
|
2024-07-06 20:24:25 +05:30
|
|
|
width="800px"
|
|
|
|
|
height="auto"
|
|
|
|
|
alt="Image Alt"
|
|
|
|
|
ref={imageEleRef}
|
|
|
|
|
/>
|
|
|
|
|
</Box>
|
2024-07-10 23:25:34 +05:30
|
|
|
</Box>
|
2024-07-14 08:58:24 +05:30
|
|
|
<Box
|
|
|
|
|
className="d-flex flex-column gap-2 mx-2 py-3"
|
|
|
|
|
style={{ minWidth: "250px" }}
|
|
|
|
|
>
|
2024-07-10 23:25:34 +05:30
|
|
|
{type &&
|
|
|
|
|
buttonActions[type].map((action) => (
|
|
|
|
|
<Button
|
|
|
|
|
className="m-0 bg-primary text-white p-3 rounded"
|
|
|
|
|
onClick={action?.action}
|
|
|
|
|
>
|
|
|
|
|
{action?.btnLabel}
|
|
|
|
|
</Button>
|
|
|
|
|
))}
|
|
|
|
|
<Box className="d-flex flex-column justify-content-between gap-2 my-2">
|
2024-07-06 20:24:25 +05:30
|
|
|
<Button
|
2024-07-10 23:25:34 +05:30
|
|
|
className="m-0 bg-primary text-white p-3 rounded"
|
2024-07-06 20:24:25 +05:30
|
|
|
onClick={rotateLeft}
|
|
|
|
|
>
|
2024-07-14 08:58:24 +05:30
|
|
|
Rotate left
|
|
|
|
|
<RotateLeftIcon />
|
2024-07-06 20:24:25 +05:30
|
|
|
</Button>
|
2024-07-10 23:25:34 +05:30
|
|
|
|
2024-07-06 20:24:25 +05:30
|
|
|
<Button
|
2024-07-10 23:25:34 +05:30
|
|
|
className="m-0 bg-primary text-white p-3 rounded"
|
2024-07-06 20:24:25 +05:30
|
|
|
onClick={rotateRight}
|
|
|
|
|
>
|
2024-07-14 08:58:24 +05:30
|
|
|
Rotate Right
|
|
|
|
|
<RotateRight />
|
2024-07-10 23:25:34 +05:30
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
className="m-0 bg-primary text-white p-3 rounded"
|
2024-07-14 08:58:24 +05:30
|
|
|
onClick={() =>
|
|
|
|
|
saveRotatedImage(
|
|
|
|
|
imageName,
|
|
|
|
|
tableNameData,
|
|
|
|
|
rotateAngle,
|
|
|
|
|
data,
|
|
|
|
|
setIsLoading
|
|
|
|
|
)
|
|
|
|
|
}
|
2024-07-10 23:25:34 +05:30
|
|
|
>
|
|
|
|
|
Save
|
2024-07-06 20:24:25 +05:30
|
|
|
</Button>
|
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
2024-07-10 23:25:34 +05:30
|
|
|
<Box className="text-left p-3 d-flex flex-column justify-content-between align-items-between h-100">
|
|
|
|
|
{keys.map((record, index) => (
|
|
|
|
|
<p>
|
|
|
|
|
<strong>{keys[index]}</strong> : {values[index]}
|
|
|
|
|
</p>
|
|
|
|
|
))}
|
|
|
|
|
</Box>
|
2024-07-06 20:24:25 +05:30
|
|
|
</Box>
|
|
|
|
|
{isLoading && <LoadingContainer loadingText={"Loading ..."} />}
|
2024-07-14 08:58:24 +05:30
|
|
|
{showEditContainer && (
|
|
|
|
|
<PlayGroundEditContainer
|
|
|
|
|
type={type}
|
2024-11-30 18:43:01 +05:30
|
|
|
year = {year}
|
|
|
|
|
imageDomain = {imageDomain}
|
2024-07-14 08:58:24 +05:30
|
|
|
rotateAngle={rotateAngle}
|
|
|
|
|
data={data}
|
|
|
|
|
s3Path={data[s3_image_column]}
|
|
|
|
|
tableName={tableName}
|
|
|
|
|
imageName={data["image_name"]}
|
|
|
|
|
setShowEditContainer={setShowEditContainer}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2024-07-06 20:24:25 +05:30
|
|
|
</Box>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default CustomQueryExecutorCard;
|