Skip to content

Commit

Permalink
commented unused fuctions and imports
Browse files Browse the repository at this point in the history
  • Loading branch information
AkshatGupta15 committed Aug 27, 2024
1 parent 77ad870 commit e7769f0
Showing 1 changed file with 76 additions and 71 deletions.
147 changes: 76 additions & 71 deletions pages/verify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
Box,
Button,
Card,
CircularProgress,
// CircularProgress,
FormControl,
Grid,
Modal,
Expand All @@ -12,25 +12,26 @@ import {
} from "@mui/material";
import React, { useEffect, useState } from "react";
import { useRouter } from "next/router";
import { green } from "@mui/material/colors";
import CheckIcon from "@mui/icons-material/Check";
import SaveIcon from "@mui/icons-material/Save";
// import { green } from "@mui/material/colors";
// import CheckIcon from "@mui/icons-material/Check";
// import SaveIcon from "@mui/icons-material/Save";
import CloudDownloadIcon from "@mui/icons-material/CloudDownload";
import styled from "@emotion/styled";
// import styled from "@emotion/styled";

import Meta from "@components/Meta";
import { PvfsParams } from "@callbacks/student/rc/pvf";
import ActiveButton from "@components/Buttons/ActiveButton";
import InactiveButton from "@components/Buttons/InactiveButton";
import { errorNotification } from "@callbacks/notifcation";
// import { errorNotification } from "@callbacks/notifcation";
import { CDN_URL } from "@callbacks/constants";
import pvfVerificationRequest from "@callbacks/Verification/[rcid]/verify";

import Custom404 from "./404";

const Input = styled("input")({
display: "none",
});
// removed for now
// const Input = styled("input")({
// display: "none",
// });
const textFieldColor = "#ff0000";
const textFieldSX = {
input: {
Expand All @@ -55,26 +56,28 @@ const boxStyle = {
const getURL = (url: string) => `${CDN_URL}/view/${url}`;

function Verify() {
const [loading, setLoading] = useState(true);
// removed for now
// const [loading, setLoading] = useState(true);
// const [pvfName, setPvfName] = useState<string>("");
// const [success, setSuccess] = useState(false);

const [openApprove, setOpenApprove] = useState(false);
const [openDeny, setOpenDeny] = useState(false);
const router = useRouter();
const [pvfName, setPvfName] = useState<string>("");
const { rcid, token } = router.query;
const rid = (rcid || "").toString();
const urlToken = (token || "").toString();
const [fileSaved, setFileSaved] = useState<File | null>(null);
const [success, setSuccess] = useState(false);
const [isVerified, setIsVerifed] = useState<boolean>();
const [remark, setRemark] = useState("");
const [row, setRow] = useState<PvfsParams>();
const transformName = (name: string) => {
const nname = name.replace(`${CDN_URL}/view/`, "");
const nameArray = nname.split(".");
const newName = nameArray[0].slice(14, -33);
const newNameWithExtension = `${newName}.${nameArray[1]}`;
return newNameWithExtension;
};
// const transformName = (name: string) => {
// const nname = name.replace(`${CDN_URL}/view/`, "");
// const nameArray = nname.split(".");
// const newName = nameArray[0].slice(14, -33);
// const newNameWithExtension = `${newName}.${nameArray[1]}`;
// return newNameWithExtension;
// };

useEffect(() => {
const getProforma = async () => {
Expand All @@ -85,9 +88,9 @@ function Verify() {
setRow(res);
if (res.is_verified) {
setIsVerifed(res.is_verified.Valid);
setPvfName(transformName(res.filename_student));
// setPvfName(transformName(res.filename_student));
}
setLoading(false);
// setLoading(false);
}
};
getProforma();
Expand Down Expand Up @@ -119,63 +122,65 @@ function Verify() {
setFileSaved(null);
router.push("/login");
};
const buttonSx = {
...(success && {
bgcolor: green[500],
"&:hover": {
bgcolor: green[700],
},
}),
height: 60,
width: "100%",
};

const handleButtonClick = () => {
if (!loading) {
setSuccess(false);
setLoading(true);
}
};
// removed for now
// const buttonSx = {
// ...(success && {
// bgcolor: green[500],
// "&:hover": {
// bgcolor: green[700],
// },
// }),
// height: 60,
// width: "100%",
// };

const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const { files } = event.target;
// removed for now
// const handleButtonClick = () => {
// if (!loading) {
// setSuccess(false);
// setLoading(true);
// }
// };
// removed for now
// const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
// const { files } = event.target;

// if (
// allPvf.filter(
// (pvf) => !(pvf.verified.Valid && !pvf.verified.Bool)
// ).length >= 5
// ) {
// errorNotification("You can only upload 5 pvf", "Cannot upload");
// setLoading(false);
// return;
// }
// // if (
// // allPvf.filter(
// // (pvf) => !(pvf.verified.Valid && !pvf.verified.Bool)
// // ).length >= 5
// // ) {
// // errorNotification("You can only upload 5 pvf", "Cannot upload");
// // setLoading(false);
// // return;
// // }

if (!(files && files.length > 0)) {
setLoading(false);
return;
}
// if (!(files && files.length > 0)) {
// setLoading(false);
// return;
// }

const file = files[0];
// const file = files[0];

if (file.size > 1280000) {
errorNotification("File size too large", "Max file size is about 1MB");
setLoading(false);
return;
}
// if (file.size > 1280000) {
// errorNotification("File size too large", "Max file size is about 1MB");
// setLoading(false);
// return;
// }

if (file.name !== pvfName) {
errorNotification(
"File must follow the name constraint",
`Expected File name: ${pvfName}`
);
setLoading(false);
return;
}
// if (file.name !== pvfName) {
// errorNotification(
// "File must follow the name constraint",
// `Expected File name: ${pvfName}`
// );
// setLoading(false);
// return;
// }

setFileSaved(file);
setSuccess(true);
setLoading(false);
};
// setFileSaved(file);
// setSuccess(true);
// setLoading(false);
// };

let content;
if (!isVerified) {
Expand Down

0 comments on commit e7769f0

Please sign in to comment.