Skip to content

Commit 652d46e

Browse files
Merge pull request #65 from CodeChefVIT/staging
Staging
2 parents c5b5e03 + e9f4fa9 commit 652d46e

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

src/app/upload/page.tsx

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,26 @@ const Page = () => {
4646
];
4747
const files = fileInputRef.current?.files as FileList | null;
4848

49-
if (!slot || !subject || !exam || !year || !files || files.length === 0) {
50-
toast.error("All fields are required.");
49+
if (!slot) {
50+
toast.error("Slot is required");
5151
return;
5252
}
53-
54-
if (files.length > 5) {
53+
if (!subject) {
54+
toast.error("Subject is required");
55+
return;
56+
}
57+
if (!exam) {
58+
toast.error("Exam is required");
59+
return;
60+
}
61+
if (!year) {
62+
toast.error("Year is required");
63+
return;
64+
}
65+
if (!files || files.length === 0) {
66+
toast.error("No files selected");
67+
return;
68+
} else if (files.length > 5) {
5569
toast.error("More than 5 files selected");
5670
return;
5771
}
@@ -99,7 +113,10 @@ const Page = () => {
99113
void toast.promise(
100114
(async () => {
101115
try {
102-
await axios.post("/api/upload", formData);
116+
const response = await axios.post<PostPDFToCloudinary>(
117+
"/api/upload",
118+
formData,
119+
);
103120

104121
setSlot("");
105122
setSubject("");
@@ -245,4 +262,4 @@ const Page = () => {
245262
);
246263
};
247264

248-
export default Page;
265+
export default Page;

src/components/searchbarSubjectList.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use client";
12
import { useState, useCallback, useRef, useEffect } from "react";
23
import { Search } from "lucide-react";
34
import debounce from "debounce";
@@ -82,8 +83,8 @@ function SearchbarSubjectList({
8283
}, [resetSearch]);
8384

8485
return (
85-
<div className="mx-4 md:mx-0">
86-
<form className=" my-2 ml-2 w-full max-w-xl">
86+
<div className="mx-0">
87+
<form className="my-2 ml-2 w-full max-w-xl">
8788
<div className="relative">
8889
<Input
8990
type="text"

0 commit comments

Comments
 (0)