1
+ 'use client'
1
2
import { Button } from "@/components/ui/button" ;
2
3
import {
3
4
Dialog ,
@@ -8,27 +9,21 @@ import {
8
9
DialogTitle ,
9
10
DialogTrigger ,
10
11
} from "@/components/ui/dialog" ;
11
- import Comment from "./Comment" ;
12
- import Comments from "./Comment" ;
13
12
import Tags from "./Tags" ;
14
13
import CommentInput from "./CommentInput" ;
15
14
import { useEffect , useRef } from "react" ;
15
+ import { SearchResults } from "@/lib/embedding" ;
16
+ import Comments from "./Comment" ;
16
17
17
- export default function DocumentView ( {
18
- documentName,
19
- documentTags,
20
- documentUrl,
21
- comments,
22
- } : {
23
- documentName : string ;
24
- documentTags : string [ ] ;
25
- documentUrl : string ;
26
- comments : { title : string ; content : string } [ ] ;
27
- } ) {
18
+ export default function DocumentView ( results
19
+ : {
20
+ results : SearchResults [ "results" ] [ number ] ;
21
+ } ) {
28
22
const embedRef = useRef < HTMLEmbedElement > ( null ) ;
29
23
30
24
useEffect ( ( ) => {
31
- fetch ( documentUrl )
25
+ console . log ( results . results . url ) ;
26
+ fetch ( results . results . url )
32
27
. then ( ( res ) => res . blob ( ) )
33
28
. then ( ( blob ) => {
34
29
const blobToBase64 = ( blob ) => {
@@ -53,14 +48,15 @@ export default function DocumentView({
53
48
}
54
49
const embed = embedRef . current ;
55
50
// replace octet-stream with pdf
56
- const url = documentUrl . replace (
51
+ const url = results . results . url . replace (
57
52
"application/octet-stream" ,
58
53
"application/pdf"
59
54
) ;
60
55
embed . setAttribute ( "type" , "application/pdf" ) ;
61
56
embed . setAttribute ( "src" , url ) ;
62
57
} ) ;
63
58
} , [ ] ) ;
59
+
64
60
return (
65
61
< Dialog aria-label = "Edit Profile" defaultOpen >
66
62
< DialogContent className = "sm:max-w-[80vw] max-[50vw]: grid gap-4 grid-cols-3 h-[90vh] bg-gray-100" >
@@ -74,12 +70,12 @@ export default function DocumentView({
74
70
</ div >
75
71
< div className = "col-span-3 sm:col-span-1 max-h-[100%] flex flex-col justify-between bg-white p-3 rounded-lg" >
76
72
< div className = "flex flex-col gap-4 overflow-y-auto" >
77
- < h1 className = "text-3xl font-bold" > { documentName } </ h1 >
78
- < Tags text = { documentTags } />
73
+ < h1 className = "text-3xl font-bold" > { results . results . name } </ h1 >
74
+ < Tags text = { results . results . tags } />
79
75
80
- < Comments comments = { comments } />
76
+ < Comments comments = { results . results . comments } />
81
77
</ div >
82
- < CommentInput />
78
+ < CommentInput documentId = { results . results . documentId } />
83
79
</ div >
84
80
</ DialogContent >
85
81
</ Dialog >
0 commit comments