Skip to content

Commit f291da6

Browse files
subjects update
1 parent d3700ce commit f291da6

File tree

3 files changed

+51
-18
lines changed

3 files changed

+51
-18
lines changed

src/app/adminupload/page.tsx

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ interface PostPDFToCloudinary {
2828

2929
function Upload() {
3030
const router = useRouter();
31-
const [subject, setSubject] = useState<string>("Digital Logic and Microprocessors[BITE202L]");
31+
const [subject, setSubject] = useState<string>(
32+
"Digital Logic and Microprocessors[BITE202L]",
33+
);
3234
const [slot, setSlot] = useState<string>("A1");
3335
const [year, setYear] = useState<string>("2011");
3436
const [exam, setExam] = useState<string>("CAT-1");
@@ -102,7 +104,12 @@ function Upload() {
102104
//Won't refresh the page if error 401
103105
(async () => {
104106
try {
105-
await axios.post("/api/admin/watermark", formData, { headers });
107+
const response = await axios.post<PostPDF>(
108+
"/api/admin/watermark",
109+
formData,
110+
{ headers },
111+
);
112+
setPdfUrl(response.data.url);
106113
} catch (error: unknown) {
107114
handleAPIError(error);
108115
// if (error instanceof AxiosError) {
@@ -398,7 +405,6 @@ function Upload() {
398405
},
399406
},
400407
);
401-
402408
}
403409

404410
if (!tag) {
@@ -421,7 +427,10 @@ function Upload() {
421427
}}
422428
//@ts-expect-error - event is not used
423429
onSuccess={(results: CloudinaryUploadWidgetProps) => {
424-
setUrls((prevUrls) => [...(prevUrls ?? []), results.info?.secure_url]);
430+
setUrls((prevUrls) => [
431+
...(prevUrls ?? []),
432+
results.info?.secure_url,
433+
]);
425434
setPublicIds((prevIds) => [
426435
...(prevIds ?? []),
427436
results.info?.public_id,
@@ -550,13 +559,16 @@ function Upload() {
550559
</button>
551560
</form>
552561
<div className="mt-4">
553-
<Link
554-
href="/watermarked.pdf"
555-
target="_blank"
556-
className="block text-blue-500 hover:underline"
557-
>
558-
View Papers
559-
</Link>
562+
{pdfUrl && (
563+
<Link
564+
href={pdfUrl}
565+
target="_blank"
566+
className="block text-blue-500 hover:underline"
567+
>
568+
View Papers
569+
</Link>
570+
)}
571+
560572
<button
561573
onClick={handleDeletePdf}
562574
className="mt-2 rounded bg-red-500 px-4 py-2 text-white hover:bg-red-600"
@@ -682,6 +694,6 @@ function Upload() {
682694
</div>
683695
</div>
684696
);
685-
};
697+
}
686698

687699
export default Upload;

src/app/api/admin/watermark/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export async function POST(req: Request, res: NextApiResponse) {
6868

6969
await writeFile(pdfPath, pdfBytes);
7070

71-
return NextResponse.json({ url: `/public/watermarked-${sessionId}.pdf` }, { status: 200 });
71+
return NextResponse.json({ url: `/watermarked-${sessionId}.pdf` }, { status: 200 });
7272
} catch (error) {
7373
return NextResponse.json({ error: "Failed to process PDF" }, { status: 500 });
7474
}

src/app/upload/select_options.ts

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const courses = [
1+
const courses = [
22
"Digital Logic and Microprocessors [BITE202L]",
33
"Structured and Object-Oriented Programming Lab [BCSE102P]",
44
"Calculus [BMAT101L]",
@@ -180,12 +180,33 @@
180180
"Big Data Analytic Applications to Electrical Systems [BECS403L]",
181181
"Big Data Analytic Applications to Electrical Systems Lab [BECS403P]",
182182
"Cyber Security [BCSE410L]",
183-
"Introduction to The Art of Hunting Cryptically [CRY2024]"
183+
"Introduction to The Art of Hunting Cryptically [CRY2024]",
184+
"Analog Circuits [BECE206L]",
185+
"Analog Communication Systems [BECE304L]",
186+
"Antenna and Microwave Engineering [BECE305L]",
187+
"AWS for Cloud Computing [BECE355L]",
188+
"Digital System Design [BECE102L]",
189+
"Sensors technology [BECE409E]",
190+
"Robotics and Automation [BECE312L]",
191+
"Random Processes [BECE207L]",
192+
"VLSI System Design [BECE303L]",
184193
];
185194

186195
const slots: string[] = [
187-
"A1", "B1", "C1", "D1", "E1", "F1", "G1",
188-
"A2", "B2", "C2", "D2", "E2", "F2", "G2"
196+
"A1",
197+
"B1",
198+
"C1",
199+
"D1",
200+
"E1",
201+
"F1",
202+
"G1",
203+
"A2",
204+
"B2",
205+
"C2",
206+
"D2",
207+
"E2",
208+
"F2",
209+
"G2",
189210
];
190211

191-
export {slots, courses};
212+
export { slots, courses };

0 commit comments

Comments
 (0)