File tree Expand file tree Collapse file tree 6 files changed +35
-2
lines changed
apps/dashboard/src/app/nebula-app/(app)/components Expand file tree Collapse file tree 6 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -370,6 +370,7 @@ export function ChatPageContent(props: {
370370 client = { client }
371371 enableAutoScroll = { enableAutoScroll }
372372 setEnableAutoScroll = { setEnableAutoScroll }
373+ sendMessage = { handleSendMessage }
373374 />
374375
375376 < div className = "container max-w-[800px]" >
Original file line number Diff line number Diff line change @@ -192,6 +192,7 @@ function Story() {
192192
193193 < BadgeContainer label = "Assistant response With request_id, Without request_id" >
194194 < Chats
195+ sendMessage = { ( ) => { } }
195196 enableAutoScroll = { false }
196197 setEnableAutoScroll = { ( ) => { } }
197198 client = { storybookThirdwebClient }
@@ -215,6 +216,7 @@ function Story() {
215216
216217 < BadgeContainer label = "Assistant markdown" >
217218 < Chats
219+ sendMessage = { ( ) => { } }
218220 enableAutoScroll = { false }
219221 setEnableAutoScroll = { ( ) => { } }
220222 client = { storybookThirdwebClient }
@@ -249,6 +251,7 @@ function Variant(props: {
249251 enableAutoScroll = { false }
250252 setEnableAutoScroll = { ( ) => { } }
251253 client = { storybookThirdwebClient }
254+ sendMessage = { ( ) => { } }
252255 authToken = "xxxxx"
253256 isChatStreaming = { false }
254257 sessionId = "xxxxx"
Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ export function Chats(props: {
5252 setEnableAutoScroll : ( enable : boolean ) => void ;
5353 enableAutoScroll : boolean ;
5454 useSmallText ?: boolean ;
55+ sendMessage : ( message : string ) => void ;
5556} ) {
5657 const { messages, setEnableAutoScroll, enableAutoScroll } = props ;
5758 const scrollAnchorRef = useRef < HTMLDivElement > ( null ) ;
@@ -169,6 +170,11 @@ export function Chats(props: {
169170 < ExecuteTransactionCardWithFallback
170171 txData = { message . data }
171172 client = { props . client }
173+ onTxSettled = { ( txHash ) => {
174+ props . sendMessage (
175+ `I've sent the transaction with hash: ${ txHash } .` ,
176+ ) ;
177+ } }
172178 />
173179 ) : (
174180 < span className = "leading-loose" >
@@ -206,6 +212,7 @@ export function Chats(props: {
206212function ExecuteTransactionCardWithFallback ( props : {
207213 txData : NebulaTxData | null ;
208214 client : ThirdwebClient ;
215+ onTxSettled : ( txHash : string ) => void ;
209216} ) {
210217 if ( ! props . txData ) {
211218 return (
@@ -216,7 +223,13 @@ function ExecuteTransactionCardWithFallback(props: {
216223 ) ;
217224 }
218225
219- return < ExecuteTransactionCard txData = { props . txData } client = { props . client } /> ;
226+ return (
227+ < ExecuteTransactionCard
228+ txData = { props . txData }
229+ client = { props . client }
230+ onTxSettled = { props . onTxSettled }
231+ />
232+ ) ;
220233}
221234
222235function MessageActions ( props : {
Original file line number Diff line number Diff line change 11import type { Meta , StoryObj } from "@storybook/react" ;
22import { useState } from "react" ;
3- import { BadgeContainer , storybookThirdwebClient } from "stories/utils" ;
3+ import {
4+ BadgeContainer ,
5+ storybookLog ,
6+ storybookThirdwebClient ,
7+ } from "stories/utils" ;
48import { ConnectButton , ThirdwebProvider } from "thirdweb/react" ;
59import {
610 ExecuteTransactionCardLayout ,
@@ -61,6 +65,9 @@ function Variant(props: {
6165 return (
6266 < BadgeContainer label = { props . label } >
6367 < ExecuteTransactionCardLayout
68+ onTxSettled = { ( txHash ) => {
69+ storybookLog ( `onTxSettled called with ${ txHash } ` ) ;
70+ } }
6471 setStatus = { setStatus }
6572 status = { status }
6673 client = { storybookThirdwebClient }
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ export type TxStatus =
4949export function ExecuteTransactionCard ( props : {
5050 txData : NebulaTxData ;
5151 client : ThirdwebClient ;
52+ onTxSettled : ( txHash : string ) => void ;
5253} ) {
5354 const [ status , setStatus ] = useState < TxStatus > ( { type : "idle" } ) ;
5455 return (
@@ -57,6 +58,7 @@ export function ExecuteTransactionCard(props: {
5758 client = { props . client }
5859 status = { status }
5960 setStatus = { setStatus }
61+ onTxSettled = { props . onTxSettled }
6062 />
6163 ) ;
6264}
@@ -66,6 +68,7 @@ export function ExecuteTransactionCardLayout(props: {
6668 client : ThirdwebClient ;
6769 status : TxStatus ;
6870 setStatus : ( status : TxStatus ) => void ;
71+ onTxSettled : ( txHash : string ) => void ;
6972} ) {
7073 const { theme } = useTheme ( ) ;
7174 const { txData } = props ;
@@ -275,13 +278,18 @@ export function ExecuteTransactionCardLayout(props: {
275278 txHash : confirmReceipt . transactionHash ,
276279 } ) ;
277280
281+ props . onTxSettled ( txHash ) ;
282+
278283 trackEvent ( {
279284 category : "nebula" ,
280285 action : "execute_transaction" ,
281286 label : "confirmed" ,
282287 chainId : txData . chainId ,
283288 } ) ;
284289 } catch {
290+ if ( txHash ) {
291+ props . onTxSettled ( txHash ) ;
292+ }
285293 props . setStatus ( {
286294 type : "failed" ,
287295 txHash : txHash ,
Original file line number Diff line number Diff line change @@ -189,6 +189,7 @@ function FloatingChatContentLoggedIn(props: {
189189 enableAutoScroll = { enableAutoScroll }
190190 setEnableAutoScroll = { setEnableAutoScroll }
191191 useSmallText
192+ sendMessage = { handleSendMessage }
192193 />
193194 ) }
194195 < ChatBar
You can’t perform that action at this time.
0 commit comments