2024-07-11 18:25:52 +05:30
|
|
|
import { toast } from "react-toastify";
|
|
|
|
|
|
2024-07-12 17:54:43 +05:30
|
|
|
const saveRotatedImage = async (imageName,tableNameData,rotateAngle,data, setIsLoading) => {
|
2024-07-11 18:25:52 +05:30
|
|
|
try {
|
2024-07-12 17:54:43 +05:30
|
|
|
console.log("data=", data)
|
2024-07-11 18:25:52 +05:30
|
|
|
if (rotateAngle === 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const payload = {
|
|
|
|
|
imageName,
|
|
|
|
|
tableNameData,
|
|
|
|
|
rotateAngle,
|
2024-07-12 17:54:43 +05:30
|
|
|
s3_path: data["s3_path"],
|
2024-07-11 18:25:52 +05:30
|
|
|
};
|
|
|
|
|
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);
|
|
|
|
|
}
|
2024-07-12 17:54:43 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default saveRotatedImage
|