This commit is contained in:
Pradeeppon01 2024-08-13 20:55:39 +05:30
parent 6c80deec0d
commit 63831d050b
4 changed files with 80 additions and 67 deletions

3
.env
View File

@ -2,4 +2,5 @@
METABASE_BASE_URL="http://metabase.usln.in/public/question/d8774923-09bb-4cd9-903b-559d417e12cf"
#VITE_REACT_APP_BACKEND_URL="http://localhost:9999"
VITE_REACT_APP_BACKEND_URL="https://api.exampaper.vidh.ai"
#VITE_REACT_APP_BACKEND_URL="https://api.exampaper.vidh.ai"
VITE_REACT_APP_BACKEND_URL="https://api.exampaper.usln.in"

View File

@ -2,8 +2,10 @@
SOURCE_DIR=/home/neuu/attendence_UI/frontend
BRANCH=part_a_playground
FRONTEND_DIR=/var/www/exampaper.vidh.ai
SERVER_IP=52.66.73.43
FRONTEND_DIR=/var/www/exampaper.usln.in
#SERVER_IP=52.66.73.43
SERVER_IP=34.131.182.12
cd ~/$SOURCE_DIR
echo "Changed into attendence UI frontend dir ....."

View File

@ -77,7 +77,7 @@ const PlayGround = () => {
const [query, setQuery] = useState("");
const [isLoading, setIsLoading] = useState(false);
const [paginationPages, setPaginationPages] = useState(null);
const [limit, setLimit] = useState("");
const [limit, setLimit] = useState("100");
const recordsPerPage = 50;
const resultsContainerRef = useRef();
const navigate = useNavigate();

View File

@ -40,13 +40,14 @@ const PlayGroundEditContainer = ({
const [marksR1, setMarksR1] = useState(null);
const [marksR2, setMarksR2] = useState(null);
const [open, setOpen] = useState(true); // Set open state to true by default
const [serialNo, setSerialNo] = useState(null);
const [notification, setNotification] = useState(null); // Notification state
const showNotification = (message, type) => {
console.log("setting notification ===== ", message);
const notificationData = { message, type}
console.log("notification data ==== ",notificationData)
const notificationData = { message, type };
console.log("notification data ==== ", notificationData);
setNotification(notificationData);
};
const handleClose = () => {
@ -56,52 +57,53 @@ const PlayGroundEditContainer = ({
console.log("data === i ==== ", data);
useEffect(() => {
const fetchImageData = async () => {
setIsLoading(true)
try{
if (data) {
const payload = {
type,
imageName,
tableName,
};
const response = await fetch(
`${
import.meta.env.VITE_REACT_APP_BACKEND_URL
}/fetchTableImageNameData`,
{
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") {
const imageData = responseData?.results;
if (imageData && imageData?.length > 0) {
const imageDataEle = imageData[0];
setQrcode(imageDataEle?.qrcode);
setBarcode(imageDataEle?.barcode);
setMarks(imageDataEle?.marks);
setMarksR1(imageDataEle?.marks_R1);
setMarksR2(imageDataEle?.marks_R2);
setSubjectCode(imageDataEle?.subject_code);
setRegisterNumber(imageDataEle?.register_number);
setTotalAbsent(imageDataEle?.total_absent);
setTotalPresent(imageDataEle?.total_present);
setTotalStudents(imageDataEle?.total_students);
setIsLoading(true);
try {
if (data) {
const payload = {
type,
imageName,
tableName,
};
const response = await fetch(
`${
import.meta.env.VITE_REACT_APP_BACKEND_URL
}/fetchTableImageNameData`,
{
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") {
const imageData = responseData?.results;
if (imageData && imageData?.length > 0) {
const imageDataEle = imageData[0];
setQrcode(imageDataEle?.qrcode);
setBarcode(imageDataEle?.barcode);
setMarks(imageDataEle?.marks);
setMarksR1(imageDataEle?.marks_R1);
setMarksR2(imageDataEle?.marks_R2);
setSubjectCode(imageDataEle?.subject_code);
setRegisterNumber(imageDataEle?.register_number);
setTotalAbsent(imageDataEle?.total_absent);
setTotalPresent(imageDataEle?.total_present);
setTotalStudents(imageDataEle?.total_students);
setSerialNo(imageDataEle?.manually_corrected_serial_no)
}
}
}
} catch (error) {
throw new Error(error);
setIsLoading(false);
}
}catch(error){
throw new Error(error)
setIsLoading(false)
}
};
fetchImageData()
fetchImageData();
console.log("the currect editor type: ", type);
}, [data]);
@ -155,11 +157,11 @@ const PlayGroundEditContainer = ({
if (responseData?.status === "success") {
showNotification("Record updated successfully !!", "success");
setShowEditContainer(false);
const queryContainerEle = document.getElementById(imageName)
console.log("querycontainerEle ===== ",queryContainerEle)
if(queryContainerEle){
queryContainerEle.classList.add("grey-background")
toast.success("Record Updated Successfully !!")
const queryContainerEle = document.getElementById(imageName);
console.log("querycontainerEle ===== ", queryContainerEle);
if (queryContainerEle) {
queryContainerEle.classList.add("grey-background");
toast.success("Record Updated Successfully !!");
}
}
} catch (error) {
@ -170,7 +172,7 @@ const PlayGroundEditContainer = ({
};
const updateRecordPartA = async () => {
setNotification({})
setNotification({});
console.log(registerNumber);
console.log(subjectCode);
console.log(barcode, qrcode);
@ -190,6 +192,7 @@ const PlayGroundEditContainer = ({
registerNumber,
imageName,
rotateAngle,
serialNo
};
const response = await fetch(
`${import.meta.env.VITE_REACT_APP_BACKEND_URL}/editPartAdata`,
@ -207,14 +210,14 @@ const PlayGroundEditContainer = ({
if (responseData?.status === "success") {
showNotification("Record updated successfully !!", "success");
setShowEditContainer(false);
const queryContainerEle = document.getElementById(imageName)
console.log("querycontainerEle ===== ",queryContainerEle)
if(queryContainerEle){
queryContainerEle.classList.add("grey-background")
const queryContainerEle = document.getElementById(imageName);
console.log("querycontainerEle ===== ", queryContainerEle);
if (queryContainerEle) {
queryContainerEle.classList.add("grey-background");
}
setTimeout(()=>{
showNotification("Record Updated Successfully !!","success")
},500)
setTimeout(() => {
showNotification("Record Updated Successfully !!", "success");
}, 500);
}
} catch (error) {
setIsLoading(false);
@ -238,7 +241,7 @@ const PlayGroundEditContainer = ({
style={{ zIndex: 100 }}
fullWidth
>
<ToastContainer/>
<ToastContainer />
<DialogContent>
<Box className="d-flex justify-content-between align-items-center gap-4">
<Box className="d-flex flex-column" style={imageStyle}>
@ -315,11 +318,18 @@ const PlayGroundEditContainer = ({
/>
</>
) : type == "PartA" ? (
<TextInputField
value={registerNumber}
setValue={setRegisterNumber}
placeholder={"Register no"}
/>
<>
<TextInputField
value={registerNumber}
setValue={setRegisterNumber}
placeholder={"Register no"}
/>
<TextInputField
value={serialNo}
setValue={setSerialNo}
placeholder={"Serial No"}
/>
</>
) : null}
{type == "PartC" ? (
<Button