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