11import { ScrollShadow } from "@/components/ui/ScrollShadow/ScrollShadow" ;
22import { cn } from "@/lib/utils" ;
33import { MarkdownRenderer } from "components/contract-components/published-contract/markdown-renderer" ;
4- import { AlertCircleIcon , ThumbsDownIcon , ThumbsUpIcon } from "lucide-react" ;
5- import { useEffect , useRef , useState } from "react" ;
4+ import { AlertCircleIcon } from "lucide-react" ;
5+ import { useEffect , useRef } from "react" ;
66import type { ThirdwebClient } from "thirdweb" ;
7- import { Button } from "../../../../@/components/ui/button" ;
8- import { useTrack } from "../../../../hooks/analytics/useTrack" ;
97import type { NebulaSwapData } from "../api/chat" ;
108import type { NebulaUserMessage , NebulaUserMessageContent } from "../api/types" ;
119import { NebulaIcon } from "../icons/NebulaIcon" ;
@@ -74,7 +72,6 @@ export function Chats(props: {
7472 enableAutoScroll : boolean ;
7573 useSmallText ?: boolean ;
7674 sendMessage : ( message : NebulaUserMessage ) => void ;
77- teamId : string | undefined ;
7875} ) {
7976 const { messages, setEnableAutoScroll, enableAutoScroll } = props ;
8077 const scrollAnchorRef = useRef < HTMLDivElement > ( null ) ;
@@ -156,7 +153,6 @@ export function Chats(props: {
156153 nextMessage = { props . messages [ index + 1 ] }
157154 authToken = { props . authToken }
158155 sessionId = { props . sessionId }
159- teamId = { props . teamId }
160156 />
161157 </ div >
162158 ) ;
@@ -176,7 +172,6 @@ function RenderMessage(props: {
176172 sendMessage : ( message : NebulaUserMessage ) => void ;
177173 nextMessage : ChatMessage | undefined ;
178174 authToken : string ;
179- teamId : string | undefined ;
180175 sessionId : string | undefined ;
181176} ) {
182177 const { message } = props ;
@@ -229,41 +224,6 @@ function RenderMessage(props: {
229224 ) ;
230225 }
231226
232- // Feedback for assistant messages
233- if ( props . message . type === "assistant" ) {
234- return (
235- < div className = "flex flex-col gap-2" >
236- < div className = "flex gap-3" >
237- { /* Left Icon */ }
238- < div className = "-translate-y-[2px] relative shrink-0" >
239- < div className = "flex size-9 items-center justify-center rounded-full border bg-card" >
240- < NebulaIcon className = "size-5 text-muted-foreground" />
241- </ div >
242- </ div >
243- { /* Right Message */ }
244- < div className = "min-w-0 grow" >
245- < ScrollShadow className = "rounded-lg" >
246- < RenderResponse
247- message = { message }
248- isMessagePending = { props . isMessagePending }
249- client = { props . client }
250- sendMessage = { props . sendMessage }
251- nextMessage = { props . nextMessage }
252- sessionId = { props . sessionId }
253- authToken = { props . authToken }
254- />
255- </ ScrollShadow >
256- < FeedbackButtons
257- sessionId = { props . sessionId }
258- authToken = { props . authToken }
259- teamId = { props . teamId }
260- />
261- </ div >
262- </ div >
263- </ div >
264- ) ;
265- }
266-
267227 return (
268228 < div className = "flex gap-3" >
269229 { /* Left Icon */ }
@@ -462,81 +422,3 @@ function StyledMarkdownRenderer(props: {
462422 />
463423 ) ;
464424}
465-
466- function FeedbackButtons ( {
467- sessionId,
468- authToken,
469- teamId,
470- } : {
471- sessionId : string | undefined ;
472- authToken : string ;
473- teamId : string | undefined ;
474- } ) {
475- const [ , setFeedback ] = useState < 1 | - 1 | null > ( null ) ;
476- const [ loading , setLoading ] = useState ( false ) ;
477- const [ thankYou , setThankYou ] = useState ( false ) ;
478- const trackEvent = useTrack ( ) ;
479-
480- async function sendFeedback ( rating : 1 | - 1 ) {
481- setLoading ( true ) ;
482- try {
483- trackEvent ( {
484- category : "siwa" ,
485- action : "submit-feedback" ,
486- rating : rating === 1 ? "good" : "bad" ,
487- sessionId,
488- teamId,
489- } ) ;
490- const apiUrl = process . env . NEXT_PUBLIC_SIWA_URL ;
491- await fetch ( `${ apiUrl } /v1/chat/feedback` , {
492- method : "POST" ,
493- headers : {
494- "Content-Type" : "application/json" ,
495- Authorization : `Bearer ${ authToken } ` ,
496- ...( teamId ? { "x-team-id" : teamId } : { } ) ,
497- } ,
498- body : JSON . stringify ( {
499- conversationId : sessionId ,
500- feedbackRating : rating ,
501- } ) ,
502- } ) ;
503- setFeedback ( rating ) ;
504- setThankYou ( true ) ;
505- } catch {
506- // TODO handle error
507- } finally {
508- setLoading ( false ) ;
509- }
510- }
511-
512- if ( thankYou ) {
513- return (
514- < div className = "mt-2 text-muted-foreground text-xs" >
515- Thank you for your feedback!
516- </ div >
517- ) ;
518- }
519-
520- return (
521- < div className = "mt-2 flex gap-2" >
522- < Button
523- className = "rounded-full border p-2 hover:bg-muted-foreground/10"
524- variant = "ghost"
525- onClick = { ( ) => sendFeedback ( - 1 ) }
526- disabled = { loading }
527- aria-label = "Thumbs down"
528- >
529- < ThumbsDownIcon className = "size-4 text-red-500" />
530- </ Button >
531- < Button
532- className = "rounded-full border p-2 hover:bg-muted-foreground/10"
533- variant = "ghost"
534- onClick = { ( ) => sendFeedback ( 1 ) }
535- disabled = { loading }
536- aria-label = "Thumbs up"
537- >
538- < ThumbsUpIcon className = "size-4 text-green-500" />
539- </ Button >
540- </ div >
541- ) ;
542- }
0 commit comments