part-a edit intergrated
This commit is contained in:
parent
c49c08e655
commit
d535c3a05f
|
|
@ -10,8 +10,8 @@ import { useNavigate } from "react-router-dom";
|
||||||
import RotateLeftIcon from "@mui/icons-material/RotateLeft";
|
import RotateLeftIcon from "@mui/icons-material/RotateLeft";
|
||||||
import RotateRightIcon from "@mui/icons-material/RotateRight";
|
import RotateRightIcon from "@mui/icons-material/RotateRight";
|
||||||
import PlayGroundEditContainer from "./PlayGroundEditContainer"
|
import PlayGroundEditContainer from "./PlayGroundEditContainer"
|
||||||
import saveRotatedImage from "./Utilities/PlaygroundUtilities"
|
import saveRotatedImage from "./Utilities/PartCPlaygroundUtilities"
|
||||||
|
import markAsPartc from "./Utilities/PartAPlaygroundUtilities";
|
||||||
|
|
||||||
const CustomQueryExecutorCard = ({
|
const CustomQueryExecutorCard = ({
|
||||||
data,
|
data,
|
||||||
|
|
@ -38,6 +38,8 @@ const CustomQueryExecutorCard = ({
|
||||||
const [tableNameData, setTableNameData] = useState(null);
|
const [tableNameData, setTableNameData] = useState(null);
|
||||||
const imageEleRef = useRef();
|
const imageEleRef = useRef();
|
||||||
const [showEditContainer,setShowEditContainer] = useState(false)
|
const [showEditContainer,setShowEditContainer] = useState(false)
|
||||||
|
const [editorType, setEditorType] = useState(null);
|
||||||
|
|
||||||
console.log("data =================== ", data);
|
console.log("data =================== ", data);
|
||||||
// console.log("image column ====== ", s3_image_column);
|
// console.log("image column ====== ", s3_image_column);
|
||||||
// console.log("s3 image ======= ", data[s3_image_column]);
|
// console.log("s3 image ======= ", data[s3_image_column]);
|
||||||
|
|
@ -278,6 +280,8 @@ const CustomQueryExecutorCard = ({
|
||||||
|
|
||||||
const showContainerAction = () =>{
|
const showContainerAction = () =>{
|
||||||
setShowEditContainer(true)
|
setShowEditContainer(true)
|
||||||
|
console.log("type === ", type)
|
||||||
|
// setEditorType(type)
|
||||||
}
|
}
|
||||||
|
|
||||||
const buttonActions = {
|
const buttonActions = {
|
||||||
|
|
@ -290,9 +294,10 @@ const CustomQueryExecutorCard = ({
|
||||||
],
|
],
|
||||||
PartA: [
|
PartA: [
|
||||||
{ btnLabel: "Mark As Front", action: updatePartAFront },
|
{ btnLabel: "Mark As Front", action: updatePartAFront },
|
||||||
{ btnLabel: "Mark As Instruction", action: updatePartAInstructions },
|
{ btnLabel: "Mark As Backpage", action: updatePartAInstructions },
|
||||||
{ btnLabel: "Initiate Process", action: initateProcess },
|
// { btnLabel: "Initiate Process", action: initateProcess },
|
||||||
{ btnLabel: "Mark As Dummy",action:markAsDummy },
|
{ btnLabel: "Mark As Dummy",action:markAsDummy },
|
||||||
|
{ btnLabel: "Mark As Part-C",action: markAsPartc },
|
||||||
{ btnLabel: "Edit",action: showContainerAction}
|
{ btnLabel: "Edit",action: showContainerAction}
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
@ -422,7 +427,7 @@ const CustomQueryExecutorCard = ({
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
className="m-0 bg-primary text-white p-3 rounded"
|
className="m-0 bg-primary text-white p-3 rounded"
|
||||||
onClick={()=>saveRotatedImage(tableName,tableNameData,rotateAngle,s3_path,data)}
|
onClick={()=>saveRotatedImage(imageName,tableNameData,rotateAngle,data, setIsLoading)}
|
||||||
>
|
>
|
||||||
Save
|
Save
|
||||||
</Button>
|
</Button>
|
||||||
|
|
@ -437,7 +442,7 @@ const CustomQueryExecutorCard = ({
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
{isLoading && <LoadingContainer loadingText={"Loading ..."} />}
|
{isLoading && <LoadingContainer loadingText={"Loading ..."} />}
|
||||||
{showEditContainer && <PlayGroundEditContainer rotateAngle={rotateAngle} data={data} s3Path={data[s3_image_column]} tableName={tableName} imageName={data["image_name"]} setShowEditContainer={setShowEditContainer}/>}
|
{showEditContainer && <PlayGroundEditContainer type={type} rotateAngle={rotateAngle} data={data} s3Path={data[s3_image_column]} tableName={tableName} imageName={data["image_name"]} setShowEditContainer={setShowEditContainer}/>}
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,13 @@ const PlayGroundEditContainer = ({
|
||||||
tableName,
|
tableName,
|
||||||
setShowEditContainer,
|
setShowEditContainer,
|
||||||
rotateAngle,
|
rotateAngle,
|
||||||
|
type
|
||||||
}) => {
|
}) => {
|
||||||
const type = "PartC";
|
// const type = "PartC";
|
||||||
|
// const type = type;
|
||||||
const dialogText = "This is dialog text";
|
const dialogText = "This is dialog text";
|
||||||
const [marks, setMarks] = useState(null);
|
const [marks, setMarks] = useState(null);
|
||||||
|
const [registerNumber, setRegisterNumber] = useState(null);
|
||||||
const [barcode, setBarcode] = useState(null);
|
const [barcode, setBarcode] = useState(null);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [qrcode, setQrcode] = useState(null);
|
const [qrcode, setQrcode] = useState(null);
|
||||||
|
|
@ -37,10 +40,12 @@ const PlayGroundEditContainer = ({
|
||||||
setBarcode(data?.barcode);
|
setBarcode(data?.barcode);
|
||||||
setMarks(data?.marks);
|
setMarks(data?.marks);
|
||||||
setSubjectCode(data?.subject_code)
|
setSubjectCode(data?.subject_code)
|
||||||
|
setRegisterNumber(data?.registerNumber)
|
||||||
}
|
}
|
||||||
|
console.log("the currect editor type: ", type)
|
||||||
}, [data]);
|
}, [data]);
|
||||||
|
|
||||||
const updateRecord = async () => {
|
const updateRecordPartC = async () => {
|
||||||
if (!marks) {
|
if (!marks) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -80,6 +85,51 @@ const PlayGroundEditContainer = ({
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const updateRecordPartA = async () => {
|
||||||
|
console.log(registerNumber)
|
||||||
|
console.log(subjectCode)
|
||||||
|
console.log(barcode, qrcode)
|
||||||
|
console.log(!registerNumber && !subjectCode && (!barcode || !qrcode))
|
||||||
|
if (!registerNumber && !subjectCode && (!barcode || !qrcode)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setIsLoading(true);
|
||||||
|
try {
|
||||||
|
const payload = {
|
||||||
|
qrcode,
|
||||||
|
barcode,
|
||||||
|
table:tableName,
|
||||||
|
s3Path,
|
||||||
|
subjectCode,
|
||||||
|
registerNumber,
|
||||||
|
imageName,
|
||||||
|
rotateAngle,
|
||||||
|
};
|
||||||
|
const response = await fetch(
|
||||||
|
`${import.meta.env.VITE_REACT_APP_BACKEND_URL}/editPartAdata`,
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={open} onClose={handleClose} maxWidth="lg" style={{zIndex:100}} fullWidth>
|
<Dialog open={open} onClose={handleClose} maxWidth="lg" style={{zIndex:100}} fullWidth>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
|
|
@ -107,17 +157,38 @@ const PlayGroundEditContainer = ({
|
||||||
setValue={setSubjectCode}
|
setValue={setSubjectCode}
|
||||||
placeholder={"Subject code"}
|
placeholder={"Subject code"}
|
||||||
/>
|
/>
|
||||||
|
{
|
||||||
|
type == 'PartC'?(
|
||||||
<TextInputField
|
<TextInputField
|
||||||
value={marks}
|
value={marks}
|
||||||
setValue={setMarks}
|
setValue={setMarks}
|
||||||
placeholder={"Marks"}
|
placeholder={"Marks"}
|
||||||
/>
|
/>
|
||||||
|
): type == 'PartA'?(
|
||||||
|
<TextInputField
|
||||||
|
value={registerNumber}
|
||||||
|
setValue={setRegisterNumber}
|
||||||
|
placeholder={"Register no"}
|
||||||
|
/>
|
||||||
|
):null
|
||||||
|
}
|
||||||
|
{
|
||||||
|
type == 'PartC'?(
|
||||||
<Button
|
<Button
|
||||||
className="bg-primary text-white p-3"
|
className="bg-primary text-white p-3"
|
||||||
onClick={() => updateRecord()}
|
onClick={() => updateRecordPartC()}
|
||||||
>
|
>
|
||||||
Update
|
Update
|
||||||
</Button>
|
</Button>
|
||||||
|
): type == 'PartA'?(
|
||||||
|
<Button
|
||||||
|
className="bg-primary text-white p-3"
|
||||||
|
onClick={() => updateRecordPartA()}
|
||||||
|
>
|
||||||
|
Update
|
||||||
|
</Button>
|
||||||
|
):null
|
||||||
|
}
|
||||||
<Button
|
<Button
|
||||||
className="bg-primary text-white p-3"
|
className="bg-primary text-white p-3"
|
||||||
onClick={() => setShowEditContainer(false)}
|
onClick={() => setShowEditContainer(false)}
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,10 @@ import HomepageCard from "./HomepageCard";
|
||||||
|
|
||||||
const PlayGrounds = () => {
|
const PlayGrounds = () => {
|
||||||
const cards = [
|
const cards = [
|
||||||
// {
|
{
|
||||||
// title: "PART - A",
|
title: "PART - A",
|
||||||
// url: "/Playground/PartA",
|
url: "/Playground/PartA",
|
||||||
// },
|
},
|
||||||
{
|
{
|
||||||
title: "PART - C",
|
title: "PART - C",
|
||||||
url: "/Playground/PartC",
|
url: "/Playground/PartC",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
import { toast } from "react-toastify";
|
||||||
|
|
||||||
|
const markAsPartc = async (data) => {
|
||||||
|
try {
|
||||||
|
console.log("data=", data)
|
||||||
|
if (rotateAngle === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const payload = {
|
||||||
|
data
|
||||||
|
};
|
||||||
|
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") {
|
||||||
|
toast.success("record updated")
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
setIsLoading(false);
|
||||||
|
throw new Error(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default markAsPartc
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import { toast } from "react-toastify";
|
import { toast } from "react-toastify";
|
||||||
|
|
||||||
export const saveRotatedImage = async (tableName,tableNameData,rotateAngle,s3_path,data) => {
|
const saveRotatedImage = async (imageName,tableNameData,rotateAngle,data, setIsLoading) => {
|
||||||
try {
|
try {
|
||||||
|
console.log("data=", data)
|
||||||
if (rotateAngle === 0) {
|
if (rotateAngle === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -9,7 +10,7 @@ export const saveRotatedImage = async (tableName,tableNameData,rotateAngle,s3_pa
|
||||||
imageName,
|
imageName,
|
||||||
tableNameData,
|
tableNameData,
|
||||||
rotateAngle,
|
rotateAngle,
|
||||||
s3_path: data[s3_image_column],
|
s3_path: data["s3_path"],
|
||||||
};
|
};
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
|
|
@ -32,3 +33,5 @@ export const saveRotatedImage = async (tableName,tableNameData,rotateAngle,s3_pa
|
||||||
throw new Error(error);
|
throw new Error(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default saveRotatedImage
|
||||||
Loading…
Reference in New Issue