Skip to content

Commit 0cbca56

Browse files
dowmload changes
1 parent 3075481 commit 0cbca56

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

src/app/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import Footer from "@/components/Footer";
66

77
const HomePage = () => {
88
return (
9-
<div>
9+
<div className="flex min-h-screen flex-col">
1010
<div>
1111
<Navbar />
1212
</div>
13-
<div className="mt-2 flex flex-col items-center justify-center gap-y-6">
13+
<div className="mt-2 flex flex-col items-center justify-center gap-y-6 flex-grow">
1414
<div className="w-full max-w-2xl space-y-6 text-center">
15-
<h1 className="phonk text-2xl md:text-3xl font-bold tracking-wider">
15+
<h1 className="phonk text-2xl font-bold tracking-wider md:text-3xl">
1616
Built by students for students
1717
</h1>
1818
<p className="text-base font-semibold">

src/components/Card.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ const Card = ({
2727
setChecked(isSelected);
2828
}, [isSelected]);
2929

30+
const handleDownload = async (paper: Paper) => {
31+
const extension = paper.finalUrl.split(".").pop();
32+
const fileName = `${extractBracketContent(paper.subject)}-${paper.exam}-${paper.slot}-${paper.year}.${extension}`;
33+
await downloadFile(paper.finalUrl, fileName);
34+
};
35+
3036
function handleCheckboxChange() {
3137
setChecked(!checked);
3238
onSelect(paper, !checked);
@@ -92,9 +98,9 @@ const Card = ({
9298
<p className="text-sm">Select</p>
9399
</div>
94100
<div className="flex gap-2" onClick={handleOpen}>
95-
<Eye size={20} />
101+
<Eye size={20} className="cursor-pointer" />
96102
<button
97-
onClick={() => downloadFile(paper.finalUrl, `${paper.subject}.jpg`)}
103+
onClick={() => handleDownload(paper)}
98104
>
99105
<Download size={20} />
100106
</button>

src/components/CatalogueContent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ const CatalogueContent = () => {
5757

5858
async function downloadFile(url: string, filename: string) {
5959
try {
60-
const response = await fetch(url, { method: "GET" });
61-
const blob = await response.blob();
60+
const response = await axios.get(url, { responseType: "blob" });
61+
const blob = new Blob([response.data]);
6262
const link = document.createElement("a");
6363
link.href = window.URL.createObjectURL(blob);
6464
link.download = filename;

src/components/Footer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import x_twitter_icon_dark from "../assets/x_twitter_icon_dark.svg";
99

1010
export default function Footer() {
1111
return (
12-
<div className="flex md:flex-row flex-col gap-y-12 max-w-7xl mx-auto items-center justify-between pt-12">
12+
<div className="flex md:flex-row flex-col gap-y-12 md:w-full md:px-12 mx-auto items-center justify-between pt-12">
1313
<div className="flex items-center">
1414
<h1 className="jost bg-gradient-to-r from-[#562EE7] to-[#FFC6E8] bg-clip-text text-center text-3xl md:text-5xl font-bold text-transparent">
1515
Papers

0 commit comments

Comments
 (0)