1
+ import axios from 'axios' ;
1
2
import * as React from 'react' ;
2
3
import InfiniteScroll from 'react-infinite-scroll-component' ;
3
4
import TextareaAutosize from 'react-textarea-autosize' ;
@@ -9,7 +10,9 @@ import type { InteractionViewProps } from './types';
9
10
10
11
export function InteractionView ( {
11
12
apiKey,
12
- userId,
13
+ agentId,
14
+ userExternalId,
15
+ userHmac,
13
16
inputPlaceholder = 'Type something...' ,
14
17
contentMaxLength = 500 ,
15
18
} : InteractionViewProps ) {
@@ -18,6 +21,40 @@ export function InteractionView({
18
21
const [ messageMap , setMessageMap ] = React . useState < Record < string , Message > > ( { } ) ;
19
22
const [ hasMore , setHasMore ] = React . useState ( true ) ;
20
23
24
+ const axiosInstance = axios . create ( {
25
+ baseURL : 'http://localhost:8080/client' , // TODO: Update
26
+ headers : {
27
+ 'Content-Type' : 'application/json' ,
28
+ 'X-PROFICIENT-API-KEY' : apiKey ,
29
+ 'X-PROFICIENT-USER-EXTERNAL-ID' : userExternalId ,
30
+ 'X-PROFICIENT-USER-HMAC' : userHmac ,
31
+ } ,
32
+ } ) ;
33
+
34
+ React . useEffect ( ( ) => {
35
+ ( async ( ) => {
36
+ console . log ( `Fetching Agent: ${ agentId } ` ) ;
37
+ // TODO: Should import from api package
38
+ interface Agent {
39
+ [ key : string ] : any ;
40
+
41
+ id : string ;
42
+ object : 'agent' ;
43
+ active : boolean ;
44
+ name : string | null ;
45
+ description : string ;
46
+ created_at : number ;
47
+ updated_at : number ;
48
+ }
49
+ try {
50
+ const { data : agent } = await axiosInstance . get < Agent > ( `/agents/${ agentId } ` ) ;
51
+ console . log ( 'SUCCESS:' , agent ) ;
52
+ } catch ( err : any ) {
53
+ console . log ( 'ERROR:' , err ?. response ?. data ) ;
54
+ }
55
+ } ) ( ) ;
56
+ } , [ axiosInstance , agentId ] ) ;
57
+
21
58
const loadNextBatch = React . useCallback ( async ( ) => {
22
59
const { messages : receivedMessages , hasMore : hasMoreNext } = await db . getMessages ( 20 , oldestMessageId . current ) ;
23
60
setMessageMap ( ( prev ) => {
0 commit comments