Skip to content

Commit 55f171a

Browse files
committed
chores
1 parent 54deae1 commit 55f171a

File tree

5 files changed

+128
-112
lines changed

5 files changed

+128
-112
lines changed

src/components/Footer.tsx

+20-16
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
FaXTwitter,
1717
FaYoutube,
1818
} from "react-icons/fa6";
19+
import { Mail } from "lucide-react";
1920

2021
export default function Footer() {
2122
const { theme } = useTheme();
@@ -30,7 +31,7 @@ export default function Footer() {
3031
return (
3132
<footer className="w-full overflow-hidden bg-gradient-to-b from-[#F3F5FF] to-[#A599CE] px-12 py-12 font-sans text-white dark:from-[#070114] dark:to-[#1F0234]">
3233
<div className="mx-auto flex max-w-[1440px] flex-col gap-y-4 lg:flex-row lg:justify-between">
33-
<div className="flex flex-col gap-4 lg:items-start lg:text-left">
34+
<div className="flex flex-col gap-4 md:items-start lg:text-left">
3435
<h1 className="jost mb-5 bg-gradient-to-r from-[#562EE7] to-[rgba(116,128,255,0.8)] bg-clip-text text-left text-7xl font-bold tracking-wide text-transparent dark:from-[#562EE7] dark:to-[#FFC6E8]">
3536
Papers
3637
</h1>
@@ -78,26 +79,29 @@ export default function Footer() {
7879
</Link>
7980
</div>
8081
</div>
81-
{/* <div className="flex flex-col items-center gap-2 text-center text-black dark:text-white lg:items-start lg:text-left">
82-
<h3 className="jost text-2xl font-semibold">Menu</h3>
83-
<Link href="/#search">Search</Link>
84-
<Link href="/#features">Features</Link>
85-
<Link href="/#faq">FAQ</Link>
86-
</div> */}
87-
{/* <div className="flex flex-col items-center gap-2 text-center text-black dark:text-white lg:items-start lg:text-left">
82+
<div className="flex flex-col gap-2 text-black dark:text-white md:items-start lg:text-left">
83+
<h3 className="jost text-2xl font-semibold">Events</h3>
84+
<Link href="https://devsoc25.codechefvit.com">DevSOC</Link>
85+
<Link href="https://gravitas.codechefvit.com">CookOff</Link>
86+
<Link href="https://gravitas.codechefvit.com">Clueminati</Link>
87+
</div>
88+
<div className="flex flex-col gap-2 text-black dark:text-white md:items-start lg:text-left">
8889
<h3 className="jost text-2xl font-semibold">Our Projects</h3>
89-
<Link href="/">Papers</Link>
90-
<Link href="/">FFCS-inator</Link>
91-
<Link href="/">Brainrot Arcade</Link>
92-
</div> */}
93-
<div className="flex flex-col gap-2 text-black dark:text-white lg:items-start lg:text-left">
90+
<Link href="https://papers.codechefvit.com">Papers</Link>
91+
<Link href="https://contactify.codechefvit.com">Contactify</Link>
92+
<Link href="https://ffcs.codechefvit.com">FFCS Combogen</Link>
93+
</div>
94+
<div className="flex flex-col gap-2 text-black dark:text-white md:items-start lg:text-left">
9495
<h3 className="jost text-2xl font-semibold">Contact Us</h3>
95-
<Link href={`mailto:[email protected]`}>
96-
96+
<Link
97+
href={`mailto:[email protected]`}
98+
className="flex flex-row items-center gap-2"
99+
>
100+
97101
</Link>
98102
</div>
99103
</div>
100-
<p className="play mt-4 text-lg text-black dark:text-white md:text-center">
104+
<p className="play mt-4 border-t border-[#130E1F] pt-12 text-center text-lg text-black dark:border-white/10 dark:text-white">
101105
Made with ❤️ by Codechef-VIT
102106
</p>
103107
</footer>

src/components/RelatedPaper.tsx

+89-81
Original file line numberDiff line numberDiff line change
@@ -6,92 +6,100 @@ import { useParams } from "next/navigation";
66
import { type IPaper, type Filters } from "@/interface";
77
import Card from "@/components/Card";
88
import Loader from "@/components/ui/loader";
9+
import { Button } from "./ui/button";
910

1011
const RelatedPapers = () => {
11-
const params = useParams();
12-
const id = params?.id as string;
13-
14-
const [currentPaper, setCurrentPaper] = useState<IPaper | null>(null);
15-
const [relatedPapers, setRelatedPapers] = useState<IPaper[]>([]);
16-
const [loading, setLoading] = useState(true);
17-
18-
useEffect(() => {
19-
const fetchData = async () => {
20-
try {
21-
const getpaper = await axios.get<IPaper>(`/api/paper-by-id/${id}`);
22-
const paper = getpaper.data;
23-
setCurrentPaper(paper);
24-
25-
const allPapersBySubject = await axios.get<Filters>("/api/papers", {
26-
params: { subject: paper.subject },
27-
});
28-
29-
const all = allPapersBySubject.data.papers;
30-
31-
const sameExam = all.filter(
32-
(p) => p._id !== paper._id && p.exam === paper.exam
33-
).slice(0, 4);
34-
35-
let finalPapers = [...sameExam];
36-
37-
if (finalPapers.length < 4) {
38-
const additional = all.filter(
39-
(p) =>
40-
p._id !== paper._id &&
41-
p.exam !== paper.exam &&
42-
!finalPapers.some((fp) => fp._id === p._id)
43-
);
44-
45-
finalPapers = [...finalPapers, ...additional.slice(0, 4 - finalPapers.length)];
46-
}
47-
48-
setRelatedPapers(finalPapers);
49-
} catch (err) {
50-
console.error("Error fetching related papers:", err);
51-
} finally {
52-
setLoading(false);
53-
}
54-
};
55-
56-
if (id) {
57-
void fetchData();
12+
const params = useParams();
13+
const id = params?.id as string;
14+
15+
const [currentPaper, setCurrentPaper] = useState<IPaper | null>(null);
16+
const [relatedPapers, setRelatedPapers] = useState<IPaper[]>([]);
17+
const [loading, setLoading] = useState(true);
18+
19+
useEffect(() => {
20+
const fetchData = async () => {
21+
try {
22+
const getpaper = await axios.get<IPaper>(`/api/paper-by-id/${id}`);
23+
const paper = getpaper.data;
24+
setCurrentPaper(paper);
25+
26+
const allPapersBySubject = await axios.get<Filters>("/api/papers", {
27+
params: { subject: paper.subject },
28+
});
29+
30+
const all = allPapersBySubject.data.papers;
31+
32+
const sameExam = all
33+
.filter((p) => p._id !== paper._id && p.exam === paper.exam)
34+
.slice(0, 4);
35+
36+
let finalPapers = [...sameExam];
37+
38+
if (finalPapers.length < 4) {
39+
const additional = all.filter(
40+
(p) =>
41+
p._id !== paper._id &&
42+
p.exam !== paper.exam &&
43+
!finalPapers.some((fp) => fp._id === p._id),
44+
);
45+
46+
finalPapers = [
47+
...finalPapers,
48+
...additional.slice(0, 4 - finalPapers.length),
49+
];
5850
}
59-
}, [id]);
60-
61-
62-
if (loading) return <Loader />;
63-
if (!currentPaper) return <div className="vipna">Paper not found.</div>;
64-
65-
return (
66-
<div className="p-6 space-y-4 vipna">
67-
<div className="flex justify-between items-center">
68-
<h2 className="text-3xl play font-semibold my-6">Explore More</h2>
69-
<Link
70-
href={`/catalogue?subject=${encodeURIComponent(currentPaper.subject)}`}
71-
passHref
72-
>
73-
<button className="border dark:border-[#7480FF] dark:bg-[#171720] border-[#734DFF] bg-[#ffffff] hover:dark:bg-[#21212d] p-3 play rounded-sm text-xl">
74-
View All
75-
</button>
76-
</Link>
7751

78-
</div>
79-
{relatedPapers.length === 0 ? (
80-
<p className="play">No related papers found.</p>
81-
) : (
82-
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
83-
{relatedPapers.map((paper) => (
84-
<Card
85-
key={paper._id}
86-
paper={paper}
87-
onSelect={() => { "" }}
88-
isSelected={false}
89-
/>
90-
))}
91-
</div>
92-
)}
52+
setRelatedPapers(finalPapers);
53+
} catch (err) {
54+
console.error("Error fetching related papers:", err);
55+
} finally {
56+
setLoading(false);
57+
}
58+
};
59+
60+
if (id) {
61+
void fetchData();
62+
}
63+
}, [id]);
64+
65+
if (loading) return <Loader />;
66+
if (!currentPaper) return <div className="vipna">Paper not found.</div>;
67+
68+
return (
69+
<div className="vipna space-y-4 p-6">
70+
<div className="flex items-center justify-between">
71+
<h2 className="play my-6 text-3xl font-semibold">Explore More</h2>
72+
73+
<Link
74+
href={`/catalogue?subject=${encodeURIComponent(currentPaper.subject)}`}
75+
passHref
76+
>
77+
<Button
78+
variant="outline"
79+
className="flex gap-2 border-2 border-black font-sans font-semibold hover:bg-slate-800 hover:text-white dark:border-[#434dba] dark:hover:border-white dark:hover:bg-slate-900"
80+
>
81+
View All
82+
</Button>
83+
</Link>
84+
</div>
85+
{relatedPapers.length === 0 ? (
86+
<p className="play">No related papers found.</p>
87+
) : (
88+
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4">
89+
{relatedPapers.map((paper) => (
90+
<Card
91+
key={paper._id}
92+
paper={paper}
93+
onSelect={() => {
94+
("");
95+
}}
96+
isSelected={false}
97+
/>
98+
))}
9399
</div>
94-
);
100+
)}
101+
</div>
102+
);
95103
};
96104

97105
export default RelatedPapers;

src/components/ShareButton.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ export default function ShareButton() {
2929
return (
3030
<Dialog>
3131
<DialogTrigger asChild>
32-
<Button>
33-
{" "}
32+
<Button className="aspect-square h-10 w-10 p-0">
3433
<FaShare />
3534
</Button>
3635
</DialogTrigger>

src/components/SideBar.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function SideBar({
9090
}, [loading]);
9191
return (
9292
<div
93-
className={`no-scrollbar sticky top-[85px] mb-0 h-[100vh] min-w-fit flex-col items-baseline overflow-y-scroll border-r-2 border-[#36266d] bg-[#f3f5ff] py-[40px] dark:bg-[#070114] md:flex`}
93+
className={`no-scrollbar mb-0 h-[100vh] min-w-fit flex-col items-baseline overflow-y-scroll border-r-2 border-[#36266d] bg-[#f3f5ff] py-[40px] dark:bg-[#070114] md:flex`}
9494
>
9595
<div className="px-[10px] md:w-[100%]">
9696
{/* <SearchBar /> */}

src/components/pdfViewer.tsx

+17-12
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { Button } from "./ui/button";
88
import { extractBracketContent } from "@/util/utils";
99
import { downloadFile } from "./CatalogueContent";
1010
import ShareButton from "./ShareButton";
11+
import Loader from "./ui/loader";
12+
import { FaGreaterThan, FaLessThan } from "react-icons/fa6";
1113

1214
// Set up PDF.js worker
1315
pdfjs.GlobalWorkerOptions.workerSrc = new URL(
@@ -73,7 +75,11 @@ export default function PdfViewer({ url, name }: PdfViewerProps) {
7375
error={
7476
<div className="p-4 text-red-500">Failed to load PDF file.</div>
7577
}
76-
loading={<div className="p-4 text-gray-500">Loading PDF...</div>}
78+
loading={
79+
<div className="p-4 text-gray-500">
80+
<Loader />
81+
</div>
82+
}
7783
noData={
7884
<div className="p-4 text-gray-500">No PDF file specified.</div>
7985
}
@@ -92,30 +98,32 @@ export default function PdfViewer({ url, name }: PdfViewerProps) {
9298
<div className="mt-4 flex flex-col items-center gap-4 rounded-lg bg-[#262635] p-4 shadow sm:flex-row">
9399
{/* Page Navigation */}
94100
<ShareButton />
95-
<Button onClick={downloadPDF}><Download/></Button>
101+
<Button onClick={downloadPDF} className="aspect-square h-10 w-10 p-0">
102+
<Download />
103+
</Button>
96104
<div className="flex items-center gap-2">
97105
<Button
98106
onClick={goToPreviousPage}
99107
disabled={pageNumber <= 1}
100-
className="rounded px-3 py-1 disabled:opacity-50 text-white transition hover:bg-[#6536c1] disabled:bg-[#706b7a]"
108+
className="h-10 w-10 rounded p-0 text-white transition hover:bg-[#6536c1] disabled:bg-[#706b7a] disabled:opacity-50"
101109
>
102-
{"<"}
110+
<FaLessThan />
103111
</Button>
104112
<input
105113
type="number"
106114
value={pageNumber}
107115
onChange={handlePageChange}
108116
min={1}
109117
max={numPages}
110-
className="w-16 rounded border p-1 text-center"
118+
className="h-10 w-16 rounded border p-1 text-center"
111119
/>
112120
<span>of {numPages ?? 1}</span>
113121
<Button
114122
onClick={goToNextPage}
115123
disabled={pageNumber >= (numPages ?? 1)}
116-
className="rounded disabled:opacity-50 px-3 py-1 text-white transition hover:bg-[#6536c1] disabled:bg-[#706b7a]"
124+
className="h-10 w-10 rounded p-0 text-white transition hover:bg-[#6536c1] disabled:bg-[#706b7a] disabled:opacity-50"
117125
>
118-
{">"}
126+
<FaGreaterThan />
119127
</Button>
120128
</div>
121129

@@ -124,23 +132,20 @@ export default function PdfViewer({ url, name }: PdfViewerProps) {
124132
<Button
125133
onClick={zoomOut}
126134
disabled={scale <= 0.25}
127-
className="rounded px-3 py-1 text-white transition hover:bg-[#6536c1] disabled:bg-gray-300"
135+
className="h-10 w-10 rounded p-0 text-white transition hover:bg-[#6536c1] disabled:bg-gray-300"
128136
>
129137
<ZoomOut />
130138
</Button>
131139
<span>{(scale * 100).toFixed(0)}%</span>
132140
<Button
133141
onClick={zoomIn}
134142
disabled={scale >= 3}
135-
className="rounded px-3 py-1 text-white transition hover:bg-[#6536c1] disabled:bg-gray-300"
143+
className="h-10 w-10 rounded p-0 text-white transition hover:bg-[#6536c1] disabled:bg-gray-300"
136144
>
137145
{<ZoomIn />}
138146
</Button>
139147
</div>
140148
</div>
141-
142-
{/* Document Name */}
143-
<p className="mt-2 text-gray-700">Viewing: {name}</p>
144149
</div>
145150
);
146151
}

0 commit comments

Comments
 (0)