Skip to content

Commit 5383d3d

Browse files
most viewed papers
1 parent ed7031e commit 5383d3d

File tree

4 files changed

+59
-29
lines changed

4 files changed

+59
-29
lines changed

ongoing-papers.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { type Paper } from "@/interface";
2+
3+
const papers: Paper[] = [
4+
{
5+
_id: "6709134c7cd783a890da2c51",
6+
finalUrl:
7+
"https://res.cloudinary.com/dtorpaj1c/image/upload/v1728647994/papers/d0wftfpiwbvnu7xj0vph.pdf",
8+
thumbnailUrl:
9+
"https://res.cloudinary.com/dtorpaj1c/image/upload/w_400,h_400,c_fill/v1728647994/papers/d0wftfpiwbvnu7xj0vph.jpg",
10+
subject: "Digital System Design [BECE102L]",
11+
slot: "B1",
12+
year: "2023",
13+
exam: "CAT-2",
14+
},
15+
16+
{
17+
_id: "6708fd8002a75017a4f08759",
18+
19+
finalUrl:
20+
"https://res.cloudinary.com/dtorpaj1c/image/upload/v1728642405/papers/orbppimhujcijj2ywhvm.pdf",
21+
thumbnailUrl:
22+
"https://res.cloudinary.com/dtorpaj1c/image/upload/w_400,h_400,c_fill/v1728642405/papers/orbppimhujcijj2ywhvm.jpg",
23+
subject: "Discrete Mathematics and Graph Theory [BMAT205L]",
24+
slot: "A2",
25+
year: "2023",
26+
exam: "CAT-2",
27+
},
28+
{
29+
_id: "6708ffbd02a75017a4f08781",
30+
finalUrl:
31+
"https://res.cloudinary.com/dtorpaj1c/image/upload/v1728642995/papers/crcehyihkyh0qlndkr42.pdf",
32+
thumbnailUrl:
33+
"https://res.cloudinary.com/dtorpaj1c/image/upload/w_400,h_400,c_fill/v1728642995/papers/crcehyihkyh0qlndkr42.jpg",
34+
subject: "Theory of Computation [BITE306L]",
35+
slot: "B1",
36+
year: "2023",
37+
exam: "CAT-2",
38+
},
39+
{
40+
_id: "67090f367cd783a890da2c05",
41+
finalUrl:
42+
"https://res.cloudinary.com/dtorpaj1c/image/upload/v1728646945/papers/ldwxp0efzedoqfpfvdtw.pdf",
43+
thumbnailUrl:
44+
"https://res.cloudinary.com/dtorpaj1c/image/upload/w_400,h_400,c_fill/v1728646945/papers/ldwxp0efzedoqfpfvdtw.jpg",
45+
subject: "Probability and Statistics [BMAT202L]",
46+
slot: "B1",
47+
year: "2023",
48+
exam: "CAT-2",
49+
},
50+
];
51+
52+
export default papers;

src/app/upload/select_options.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ const courses = [
190190
"Robotics and Automation [BECE312L]",
191191
"Random Processes [BECE207L]",
192192
"VLSI System Design [BECE303L]",
193+
"Digital Communication System [BECE306L]",
193194
];
194195

195196
const slots: string[] = [

src/components/Card.tsx

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,9 @@ const Card = ({
4747
link.download = filename;
4848
link.click();
4949
window.URL.revokeObjectURL(link.href);
50-
} catch (error) {
51-
}
50+
} catch (error) {}
5251
}
5352

54-
function handleOpen() {
55-
const storedPapers = JSON.parse(
56-
localStorage.getItem("clickedPapers") ?? "[]",
57-
);
58-
const paperExists = storedPapers.some(
59-
(storedPaper: Paper) => storedPaper._id === paper._id,
60-
);
61-
if (!paperExists) {
62-
const updatedPapers = [paper, ...storedPapers];
63-
const lastThreePapers = updatedPapers.slice(0, 4);
64-
localStorage.setItem("clickedPapers", JSON.stringify(lastThreePapers));
65-
}
66-
window.open(paper.finalUrl, "_blank");
67-
}
6853
if (paper.finalUrl.startsWith("http://")) {
6954
paper.finalUrl = paper.finalUrl.replace("http://", "https://");
7055
}
@@ -105,7 +90,9 @@ const Card = ({
10590
<p className="text-sm">Select</p>
10691
</div>
10792
<div className="flex gap-2">
108-
<Eye size={20} className="cursor-pointer" onClick={handleOpen} />
93+
<Link href={paper.finalUrl} target="_blank" rel="noopener noreferrer">
94+
<Eye size={20} />
95+
</Link>
10996
<button onClick={() => handleDownload(paper)}>
11097
<Download size={20} />
11198
</button>

src/components/StoredPapers.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,16 @@
1-
"use client";
2-
import { useEffect, useState } from "react";
31
import PreviewCard from "@/components/PreviewCard";
42
import { type Paper } from "@/interface";
3+
import papers from "ongoing-papers";
54

65
function StoredPapers() {
7-
const [papers, setPapers] = useState<Paper[]>([]);
8-
9-
useEffect(() => {
10-
const storedPapers = JSON.parse(
11-
localStorage.getItem("clickedPapers") ?? "[]"
12-
);
13-
14-
setPapers(storedPapers);
15-
}, []);
166

177
if (papers.length === 0) {
188
return null;
199
}
2010

2111
return (
2212
<>
23-
<p className="mb-4 text-center font-semibold">Recently Viewed Papers</p>
13+
<p className="mb-4 text-center font-semibold">Most Viewed Papers</p>
2414
<div className="flex flex-wrap justify-center gap-4">
2515
{papers.map((paper: Paper) => (
2616
<PreviewCard key={paper._id} paper={paper} />

0 commit comments

Comments
 (0)