@@ -3,7 +3,7 @@ import { useState, useEffect } from "react";
3
3
import axios , { type AxiosResponse } from "axios" ;
4
4
import Footer from "@/components/Footer" ;
5
5
import Navbar from "@/components/Navbar" ;
6
- import { Eye , Maximize } from "lucide-react" ;
6
+ import { Download , Eye , Maximize } from "lucide-react" ;
7
7
import { useRouter } from "next/navigation" ;
8
8
import { Worker } from "@react-pdf-viewer/core" ;
9
9
import { Viewer } from "@react-pdf-viewer/core" ;
@@ -15,23 +15,19 @@ import {
15
15
type RenderZoomInProps ,
16
16
type RenderCurrentScaleProps ,
17
17
} from "@react-pdf-viewer/zoom" ;
18
+ import { getFilePlugin } from "@react-pdf-viewer/get-file" ;
19
+
18
20
import {
19
21
fullScreenPlugin ,
20
22
type RenderEnterFullScreenProps ,
21
23
} from "@react-pdf-viewer/full-screen" ;
24
+
22
25
import "@react-pdf-viewer/full-screen/lib/styles/index.css" ;
23
26
import "@react-pdf-viewer/core/lib/styles/index.css" ;
24
27
import "@react-pdf-viewer/zoom/lib/styles/index.css" ;
25
28
import Loader from "@/components/ui/loader" ;
26
29
import Link from "next/link" ;
27
-
28
- interface PaperResponse {
29
- finalUrl : string ;
30
- subject : string ;
31
- year : string ;
32
- slot : string ;
33
- exam : string ;
34
- }
30
+ import { PaperResponse } from "@/interface" ;
35
31
36
32
interface ErrorResponse {
37
33
message : string ;
@@ -45,7 +41,7 @@ export default function PaperPage({ params }: Params) {
45
41
const [ paper , setPaper ] = useState < PaperResponse | null > ( null ) ;
46
42
const [ error , setError ] = useState < string | null > ( null ) ;
47
43
const router = useRouter ( ) ;
48
-
44
+ const getFilePluginInstance = getFilePlugin ( ) ;
49
45
const zoomPluginInstance = zoomPlugin ( ) ;
50
46
const { CurrentScale, ZoomIn, ZoomOut } = zoomPluginInstance ;
51
47
const fullScreenPluginInstance = fullScreenPlugin ( ) ;
@@ -116,7 +112,14 @@ export default function PaperPage({ params }: Params) {
116
112
) }
117
113
</ ZoomIn >
118
114
</ div >
119
- < div className = "hidden gap-x-4 md:flex" >
115
+ < div className = "hidden gap-x-4 md:flex md:items-center" >
116
+ < getFilePluginInstance . Download >
117
+ { ( props ) => (
118
+ < button className = "" onClick = { props . onClick } >
119
+ < Download />
120
+ </ button >
121
+ ) }
122
+ </ getFilePluginInstance . Download >
120
123
< EnterFullScreen >
121
124
{ ( props : RenderEnterFullScreenProps ) => (
122
125
< button onClick = { ( ) => props . onClick ( ) } >
@@ -126,15 +129,19 @@ export default function PaperPage({ params }: Params) {
126
129
</ EnterFullScreen >
127
130
</ div >
128
131
< Link className = "flex md:hidden" href = { paper . finalUrl } >
129
- < Eye size = { 20 } />
132
+ < Download />
130
133
</ Link >
131
134
</ div >
132
135
133
136
< Worker workerUrl = "https://unpkg.com/[email protected] /build/pdf.worker.min.js" >
134
137
< div className = "border-1 w-[95%] overflow-x-hidden md:w-[80%]" >
135
138
< Viewer
136
139
fileUrl = { paper . finalUrl }
137
- plugins = { [ zoomPluginInstance , fullScreenPluginInstance ] }
140
+ plugins = { [
141
+ zoomPluginInstance ,
142
+ getFilePluginInstance ,
143
+ fullScreenPluginInstance ,
144
+ ] }
138
145
/>
139
146
</ div >
140
147
</ Worker >
0 commit comments