-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1d32463
commit 8af6140
Showing
6 changed files
with
17 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,15 @@ | ||
'use client'; | ||
import supabase from "@/config/supabase"; | ||
import { RawCourseID } from "@/types/courses"; | ||
import { Button } from "@mui/joy"; | ||
import Link from "next/link"; | ||
import { DownloadCloud } from "react-feather"; | ||
|
||
const DownloadSyllabus = ({ courseId }: { courseId: RawCourseID }) => { | ||
const handleDownload = async () => { | ||
|
||
const fileURL = `${process.env.NEXT_PUBLIC_SUPABASE_URL}storage/v1/object/public/syllabus/${encodeURIComponent(courseId)}.pdf`; | ||
const link = document.createElement('a') | ||
link.href = fileURL | ||
link.setAttribute('download', courseId+'.pdf') | ||
document.body.appendChild(link) | ||
link.click() | ||
link.remove() | ||
} | ||
const fileURL = `${process.env.NEXT_PUBLIC_SUPABASE_URL}storage/v1/object/public/syllabus/${encodeURIComponent(courseId)}.pdf`; | ||
|
||
return <Button variant="outlined" startDecorator={<DownloadCloud />} onClick={handleDownload}>Download PDF</Button> | ||
return <Link href={fileURL} target="_blank"> | ||
<Button variant="outlined" startDecorator={<DownloadCloud />}>Download PDF</Button> | ||
</Link> | ||
} | ||
|
||
export default DownloadSyllabus; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters