import * as React from "react";
import Button from "@mui/material/Button";
import Dialog from "@mui/material/Dialog";
import AppBar from "@mui/material/AppBar";
import Toolbar from "@mui/material/Toolbar";
import IconButton from "@mui/material/IconButton";
import Typography from "@mui/material/Typography";
import CloseIcon from "@mui/icons-material/Close";
import Slide from "@mui/material/Slide";
import ZoomInIcon from "@mui/icons-material/ZoomIn";
import ZoomOutIcon from "@mui/icons-material/ZoomOut";
import RotateRightIcon from "@mui/icons-material/RotateRight";
import { Box } from "@mui/material";
import ArrowBackIcon from "@mui/icons-material/ArrowBack";
import ArrowForwardIcon from "@mui/icons-material/ArrowForward";
import TextInputField from "./TextInputField";
import { useEffect, useState } from "react";
import LoadingContainer from "./LoadingContainer";
const Transition = React.forwardRef(function Transition(props, ref) {
return ;
});
export default function DummyDuplicatesPreview({
type,
barcode,
dummyDuplicatesData,
setIsDialogOpen,
}) {
const [open, setOpen] = React.useState(false);
const [scaleWidthValue, setScaleWidthValue] = React.useState(80);
const [rotateValue, setRotateValue] = React.useState(0);
const [partAResults, setPartAResults] = React.useState([]);
const [partCResults, setPartCResults] = React.useState([]);
const [isLoading, setIsLoading] = React.useState(false);
const [partAImageIndex, setPartAImageIndex] = React.useState(0);
const [partCImageIndex, setPartCImageIndex] = React.useState(0);
const [inputBarcode, setInputBarcode] = useState(null);
const [inputSerialNo, setInputSerialNo] = useState(null);
const [inputSubjectCode,setInputSubjectCode] = useState(null)
const [inputRegisterNumber,setInputRegisterNumber] = useState(null)
const handleClickOpen = () => {
setOpen(true);
};
const handleClose = () => {
setOpen(false);
setIsDialogOpen(false);
};
React.useEffect(() => {
handleClickOpen();
}, []);
useEffect(() => {
console.log("fetchDuplicateBarcodeInfo .........");
const fetchDuplicateBarcodeInfo = async () => {
setIsLoading(true);
console.log("fetching barcode info .....");
try {
const response = await fetch(
`${
import.meta.env.VITE_REACT_APP_BACKEND_URL
}/fetchDummyDuplicateBarcodeInfo`,
{
method: "POST",
body: JSON.stringify({
type,
barcode,
}),
headers: {
"Content-Type": "application/json",
},
}
);
const responseData = await response.json();
setIsLoading(false);
console.log("Barcode info Response Data ==== ", responseData);
if (responseData?.status == "success") {
console.log("success");
setIsLoading(false);
setPartAResults(responseData?.part_a_results);
setPartCResults(responseData?.part_c_results);
}
} catch (error) {
setIsLoading(false);
throw new Error(error);
}
};
fetchDuplicateBarcodeInfo();
}, []);
const ZoomInImage = () => {
console.log("Zooming In Image ....");
const elements = document.getElementsByClassName("scanned-img");
for (var ele of elements) {
console.log("Ele is : ", ele);
const newScaleWidthValue = scaleWidthValue + 10;
setScaleWidthValue(newScaleWidthValue);
// ele.style.transform = `scale(${newScaleValue})`;
ele.style.width = `${newScaleWidthValue}%`;
}
};
const ZoomOutImage = () => {
console.log("Zooming Out Image ....");
const elements = document.getElementsByClassName("scanned-img");
for (var ele of elements) {
console.log("Ele is : ", ele);
const newScaleWidthValue = scaleWidthValue - 10;
setScaleWidthValue(newScaleWidthValue);
// ele.style.transform = `scale(${newScaleValue})`;
ele.style.width = `${newScaleWidthValue}%`;
}
};
const RotateImageLeft = () => {
const elements = document.getElementsByClassName("scanned-img");
for (var ele of elements) {
console.log("Ele is : ", ele);
const newRotateValue = rotateValue - 90;
setRotateValue(newRotateValue);
ele.style.transform = `rotate(${newRotateValue}deg)`;
}
};
const RotateImageRight = () => {
const elements = document.getElementsByClassName("scanned-img");
for (var ele of elements) {
console.log("Ele is : ", ele);
const newRotateValue = rotateValue + 90;
setRotateValue(newRotateValue);
ele.style.transform = `rotate(${newRotateValue}deg)`;
}
};
return (
{isLoading && }
);
}