3
3
import { Minus , Plus } from "lucide-react" ;
4
4
import * as React from "react" ;
5
5
6
+ import { Badge } from "@/components/ui/badge" ;
6
7
import { Button } from "@/components/ui/button" ;
7
8
import {
8
9
Drawer ,
@@ -14,27 +15,107 @@ import {
14
15
DrawerTitle ,
15
16
DrawerTrigger ,
16
17
} from "@/components/ui/drawer" ;
18
+ import { useEffect } from "react" ;
19
+ import { createEthstorageArticleUrl } from "../utils" ;
17
20
import { ReviewCard } from "./ReviewCard" ;
21
+ import { ReviewTabs } from "./ReviewTabs" ;
18
22
19
- export const ArticleDrawer = ( { articleKey = "" } : { articleKey ?: string } ) => {
20
- const [ goal , setGoal ] = React . useState ( 350 ) ;
23
+ export const DIRECTORY_ADDRESS_MANAGER =
24
+ "0x649318865AF1A2aE6EE1C5dE9aD6cF6162e28E22" ;
21
25
22
- function onClick ( adjustment : number ) {
23
- setGoal ( Math . max ( 200 , Math . min ( 400 , goal + adjustment ) ) ) ;
24
- }
26
+ export const DIRECTORY_ADDRESS_EDITOR =
27
+ "0xF8C27D74473A2eE89c52fb594Aef8b239a0b7194" ;
28
+
29
+ // DIRECTORY_ADDRESS_TEMPLATE = '0xcf4dc300ab2ea01151945d5b06bd281da27dc943';
30
+
31
+ export const ArticleDrawer = ( {
32
+ articleKey = "" ,
33
+ isReview,
34
+ } : { articleKey ?: string ; isReview : boolean } ) => {
35
+ const reviewers = [ "vitalik-eth" , "cz" ] ;
36
+ const [ currentReviewerIndex , setCurrentReviewerIndex ] = React . useState ( 0 ) ;
37
+ const [ reviews , setReviews ] = React . useState < string [ ] > ( [ ] ) ;
38
+ const [ factcheckResult , setFactcheckResult ] = React . useState < any > ( { } ) ;
39
+
40
+ const reviewUrls = React . useMemo ( ( ) => {
41
+ return reviewers . map ( ( reviewer ) =>
42
+ createEthstorageArticleUrl (
43
+ DIRECTORY_ADDRESS_EDITOR ,
44
+ `review-${ reviewer } /${ articleKey } ` ,
45
+ ) ,
46
+ ) ;
47
+ } , [ articleKey ] ) ;
48
+
49
+ const factCheckUrl = React . useMemo ( ( ) => {
50
+ return createEthstorageArticleUrl (
51
+ DIRECTORY_ADDRESS_EDITOR ,
52
+ `factcheck/${ articleKey . replace ( ".md" , ".json" ) } ` ,
53
+ ) ;
54
+ } , [ articleKey ] ) ;
55
+
56
+ useEffect ( ( ) => {
57
+ console . log ( "factCheckUrl" , factCheckUrl ) ;
58
+ fetch ( factCheckUrl ) . then ( async ( res ) => {
59
+ const results = await res . json ( ) ;
60
+ console . log ( "factcheck results" , results ) ;
61
+ setFactcheckResult ( results ) ;
62
+ } ) ;
63
+
64
+ Promise . all (
65
+ reviewUrls . map ( ( reviewUrl : string ) => {
66
+ console . log ( "reviewUrl" , reviewUrl ) ;
67
+ return fetch ( reviewUrl ) . then ( async ( res ) => res . text ( ) ) ;
68
+ } ) ,
69
+ ) . then ( ( results ) => {
70
+ console . log ( "results" , results ) ;
71
+
72
+ setReviews ( results ) ;
73
+ } ) ;
74
+ } , [ articleKey , reviewUrls , factCheckUrl ] ) ;
25
75
26
76
return (
27
77
< DrawerContent >
28
- < div className = "mx-auto w-full max-w-sm " >
78
+ < div className = "mx-auto w-full max-w-[600px] " >
29
79
< DrawerHeader >
30
80
< DrawerTitle > { articleKey } </ DrawerTitle >
31
- < DrawerDescription > Set your daily activity goal.</ DrawerDescription >
81
+ < DrawerDescription >
82
+ { isReview
83
+ ? "Reviews by AI review agents"
84
+ : "Fact Check by AI agent base on Polymarket and trusted domains" }
85
+ </ DrawerDescription >
32
86
</ DrawerHeader >
33
87
< div className = "p-4 pb-0" >
34
- < div className = "flex items-center justify-center space-x-2" >
35
- < ReviewCard />
36
- </ div >
37
- < div className = "mt-3 h-[120px]" > test</ div >
88
+ { isReview ? (
89
+ < ReviewTabs
90
+ reviewers = { reviewers }
91
+ reviews = { reviews }
92
+ reviewUrls = { reviewUrls }
93
+ />
94
+ ) : (
95
+ < div >
96
+ < div > Claim: { factcheckResult . claim } </ div >
97
+ < div > { factcheckResult . is_true ? "✅True" : "False" } </ div >
98
+ < div > Confidence Level: { factcheckResult . confidence_level } </ div >
99
+ < div > Citations: { factcheckResult . citations } </ div >
100
+ < div > Explanation: { factcheckResult . explanation } </ div >
101
+ < div >
102
+ < a
103
+ className = "underline"
104
+ href = { factCheckUrl }
105
+ target = "_blank"
106
+ rel = "noreferrer"
107
+ >
108
+ on-chain record
109
+ </ a >
110
+ </ div >
111
+ </ div >
112
+ ) }
113
+
114
+ { /* <Badge>{currentReviewer}</Badge>
115
+ <div className="flex p-0 items-center justify-center space-x-2 overflow-y-hidden">
116
+ <ReviewCard reviewer="" comment={reviews[0]} />
117
+ </div> */ }
118
+ { /* <div className="mt-3 h-[120px]">test</div> */ }
38
119
</ div >
39
120
< DrawerFooter >
40
121
{ /* <DrawerClose asChild>
0 commit comments