Skip to content

Commit e96e22b

Browse files
authored
Merge pull request #139 from CodeChefVIT/buildNResponsiveness
Build fix, refactor, search on click n responsiveness
2 parents 3891839 + 3eca3a3 commit e96e22b

File tree

19 files changed

+115
-128
lines changed

19 files changed

+115
-128
lines changed

src/app/actions/get-papers-by-id.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const fetchPaperID = async (id: string): Promise<PaperResponse> => {
1212
return response.data;
1313
} catch (err: unknown) {
1414
if (axios.isAxiosError(err)) {
15-
console.error("Axios error:", err.response?.data || err.message);
15+
console.error("Axios error:", err.response?.data ?? err.message);
1616
const errorMessage = (err.response?.data as { message?: string })?.message ?? "Failed to fetch paper";
1717
throw new Error(errorMessage);
1818
} else {

src/app/api/ai-upload/route.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ export async function POST(req: Request) {
154154
uploadPreset,
155155
);
156156
} catch (error) {
157+
console.error("Error creating PDF:", error);
157158
return NextResponse.json(
158159
{ error: "Failed to process PDF" },
159160
{ status: 500 },

src/app/api/upload/route.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export async function POST(req: Request) {
8383
uploadPreset,
8484
);
8585
} catch (error) {
86+
console.error("Error creating PDF:", error);
8687
return NextResponse.json(
8788
{ error: "Failed to process PDF" },
8889
{ status: 500 },

src/app/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Hero from "@/components/screens/Hero";
44

55
const HomePage = () => {
66
return (
7-
<div className="vipna flex min-h-screen w-full flex-col space-y-8">
7+
<div >
88
<Hero />
99
<Info />
1010
<Faq />

src/app/paper/[id]/page.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { fetchPaperID } from "@/app/actions/get-papers-by-id";
2-
import Footer from "@/components/Footer";
3-
import Navbar from "@/components/Navbar";
2+
43
import PdfViewer from "@/components/pdfViewer";
54
import ShareButton from "@/components/ShareButton";
65
import Loader from "@/components/ui/loader";

src/app/upload/page.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import axios, { AxiosError } from "axios";
44
import toast from "react-hot-toast";
55
import { handleAPIError } from "../../util/error";
66
import { Button } from "@/components/ui/button";
7-
import Navbar from "@/components/Navbar";
8-
import Footer from "@/components/Footer";
7+
98
import { type APIResponse } from "@/interface";
109
import Dropzone from "react-dropzone";
1110

src/app/upload/page_not_AI.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ import axios from "axios";
55
import toast from "react-hot-toast";
66
import { handleAPIError } from "../../util/error";
77
import { Button } from "@/components/ui/button";
8-
import Navbar from "@/components/Navbar";
9-
import Footer from "@/components/Footer";
8+
109
import { type APIResponse } from "@/interface";
1110
import {
1211
slots,
1312
years,
14-
campuses,
1513
semesters,
1614
exams,
1715
} from "@/components/select_options";

src/components/Card.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const Card = ({ paper, onSelect, isSelected }: CardProps) => {
6464
return (
6565
<div
6666
className={cn(
67-
"overflow-hidden play rounded-sm border-2 dark:border-[#36266D] border-[#734DFF] bg-[#FFFFFF] dark:bg-[#171720] hover:bg-[#EFEAFF] hover:dark:bg-[#262635]",
67+
"play overflow-hidden rounded-sm border-2 border-[#734DFF] bg-[#FFFFFF] hover:bg-[#EFEAFF] dark:border-[#36266D] dark:bg-[#171720] hover:dark:bg-[#262635]",
6868
checked && "bg-[#262635]",
6969
)}
7070
>
@@ -74,7 +74,7 @@ const Card = ({ paper, onSelect, isSelected }: CardProps) => {
7474
alt={paper.subject}
7575
width={320}
7676
height={180}
77-
className=" w-full object-cover p-4 pb-3 md:h-[250px]"
77+
className="w-full object-cover p-4 pb-3 md:h-[250px]"
7878
/>
7979

8080
<div className="justify-center">
@@ -90,7 +90,7 @@ const Card = ({ paper, onSelect, isSelected }: CardProps) => {
9090
</div>
9191
</div>
9292

93-
<div className="h-[1px] w-full dark:bg-[#36266D] bg-[#734DFF]" />
93+
<div className="h-[1px] w-full bg-[#734DFF] dark:bg-[#36266D]" />
9494

9595
<div className="space-y-2 p-4">
9696
<div className="font-sans text-base font-semibold">
@@ -106,7 +106,7 @@ const Card = ({ paper, onSelect, isSelected }: CardProps) => {
106106
</div>
107107
</Link>
108108

109-
<div className="hidden play items-center justify-between gap-2 px-4 pb-4 md:flex">
109+
<div className="play hidden items-center justify-between gap-2 px-4 pb-4 md:flex">
110110
<div className="flex items-center gap-2">
111111
<input
112112
checked={checked}
@@ -127,4 +127,4 @@ const Card = ({ paper, onSelect, isSelected }: CardProps) => {
127127
);
128128
};
129129

130-
export default Card;
130+
export default Card;

src/components/CatalogueContent.tsx

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,13 @@ import { useEffect, useState } from "react";
55
import axios, { type AxiosError } from "axios";
66
import { Button } from "@/components/ui/button";
77
import { type IPaper, type Filters } from "@/interface";
8-
import { FilterDialog } from "@/components/FilterDialog";
98
import Card from "./Card";
109
import { extractBracketContent } from "@/util/utils";
1110
import { useRouter } from "next/navigation";
12-
import SearchBarChild from "./Searchbar/searchbar-child";
1311
import Loader from "./ui/loader";
14-
import { campuses, semesters } from "./select_options";
15-
import SearchBar from "./Searchbar/searchbar";
12+
1613
import filterIcon from "../assets/filterIcon.svg";
1714
import Image from "next/image";
18-
import { XIcon } from "lucide-react";
1915
import SideBar from "../components/SideBar";
2016

2117
const CatalogueContent = () => {
@@ -25,18 +21,7 @@ const CatalogueContent = () => {
2521
const exams = searchParams.get("exams")?.split(",");
2622
const slots = searchParams.get("slots")?.split(",");
2723
const years = searchParams.get("years")?.split(",");
28-
const semesters = searchParams.get("semesters")?.split(",");
29-
const campuses = searchParams.get("campuses")?.split(",");
3024

31-
const [selectedExams, setSelectedExams] = useState<string[] | undefined>(
32-
exams,
33-
);
34-
const [selectedSlots, setSelectedSlots] = useState<string[] | undefined>(
35-
slots,
36-
);
37-
const [selectedYears, setSelectedYears] = useState<string[] | undefined>(
38-
years,
39-
);
4025

4126
// const handleResetFilters = () => {
4227
// setSelectedExams([]);
@@ -170,7 +155,7 @@ const CatalogueContent = () => {
170155

171156
void fetchPapers();
172157
}
173-
}, [subject, exams?.join(","), slots?.join(","), years?.join(",")]); //changed because userRouter() changes everytime
158+
}, [exams, slots, subject, years]); //changed because userRouter() changes everytime
174159
return (
175160
<div className="relative flex min-h-screen p-0">
176161
<SideBar

src/components/FilterDialog.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const FilterDialog = ({
4242
const [selectedYears, setSelectedYears] = useState<string[]>(
4343
initialYears ?? [],
4444
);
45-
const [selectedCampuses, setSelectedCampuses] = useState<string[]>(
45+
const [, setSelectedCampuses] = useState<string[]>(
4646
initialYears ?? [],
4747
);
4848
const [selectedSemesters, setSelectedSemesters] = useState<string[]>(
@@ -56,7 +56,7 @@ export const FilterDialog = ({
5656
setSelectedYears(initialYears ?? []);
5757
setSelectedCampuses(initialCampuses ?? []);
5858
setSelectedSemesters(initialSemesters ?? []);
59-
}, [initialExams, initialSlots, initialYears]);
59+
}, [initialCampuses, initialExams, initialSemesters, initialSlots, initialYears]);
6060

6161
const exams = filterOptions.uniqueExams.map((exam) => ({
6262
label: exam,
@@ -74,10 +74,10 @@ export const FilterDialog = ({
7474
label: semester,
7575
value: semester,
7676
}));
77-
const campuses = filterOptions.uniqueCampuses.map((campus) => ({
78-
label: campus,
79-
value: campus,
80-
}));
77+
// const campuses = filterOptions.uniqueCampuses.map((campus) => ({
78+
// label: campus,
79+
// value: campus,
80+
// }));
8181
const handleFilterClick = () => {
8282
onApplyFilters(selectedExams, selectedSlots, selectedYears);
8383
setOpen(false);

0 commit comments

Comments
 (0)