Skip to content

Commit

Permalink
Merge pull request #322 from AkshatGupta15/main
Browse files Browse the repository at this point in the history
Removed PVF view mentor uploaded buttons in admin & student ,also upl…
  • Loading branch information
bmerchant22 authored Aug 27, 2024
2 parents e67a564 + e7769f0 commit 1f559fc
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 78 deletions.
4 changes: 2 additions & 2 deletions pages/admin/rc/[rcid]/pvf/[pvfid]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ function AdminPvfView() {
<CloudDownloadIcon sx={{ marginRight: "10px" }} />
<span>View Student Uploaded PVF</span>
</Button>
<Button
{/* <Button
disabled={row?.filename_mentor === ""}
variant="contained"
onClick={() => {
Expand All @@ -232,7 +232,7 @@ function AdminPvfView() {
>
<CloudDownloadIcon sx={{ marginRight: "10px" }} />
<span>View Mentor Uploaded PVF</span>
</Button>
</Button> */}
</Grid>
{/* removed for now */}
<Grid item xs={12} md={12} key="status" padding={0}>
Expand Down
4 changes: 2 additions & 2 deletions pages/student/rc/[rcid]/pvf/[pvfid]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ function View() {
<CloudDownloadIcon sx={{ marginRight: "10px" }} />
<span>View Student Uploaded PVF</span>
</Button>
<Button
{/* <Button
disabled={row?.filename_mentor === ""}
variant="contained"
onClick={() => {
Expand All @@ -198,7 +198,7 @@ function View() {
>
<CloudDownloadIcon sx={{ marginRight: "10px" }} />
<span>View Mentor Uploaded PVF</span>
</Button>
</Button> */}
</Grid>
{/* removed for now */}
{/* <Grid item xs={12} md={12} key="status" padding={0}>
Expand Down
153 changes: 79 additions & 74 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 Expand Up @@ -299,7 +304,7 @@ function Verify() {
<Grid
item
xs={12}
md={6}
md={12}
key="view"
padding={0}
marginBottom={7}
Expand All @@ -319,7 +324,7 @@ function Verify() {
<span>View Student Uploaded PVF</span>
</Button>
</Grid>
<Grid item xs={12} md={6} key="upload" padding={0}>
{/* <Grid item xs={12} md={6} key="upload" padding={0}>
<label htmlFor="icon-button-file">
<Input
accept="application/pdf"
Expand Down Expand Up @@ -356,7 +361,7 @@ function Verify() {
)}
</Button>
</label>
</Grid>
</Grid> */}
<Grid
item
xs={12}
Expand Down

0 comments on commit 1f559fc

Please sign in to comment.