@@ -46,6 +46,7 @@ import { ProductCardWrapper } from 'components/ProductCard/ProductCardWrapper'
46
46
import { DashboardProps } from 'components/Dashboard/DashboardWrapper'
47
47
import { FilteredTableMessage } from 'components/AccessTokens/FilteredTableMessage/FilteredTableMessage'
48
48
import { CreatedDbLabCards } from 'components/CreateDbLabCards/CreateDbLabCards'
49
+ import { convertThread } from "../../api/bot/convertThread" ;
49
50
50
51
interface DashboardWithStylesProps extends DashboardProps {
51
52
classes : ClassesType
@@ -163,6 +164,8 @@ class Dashboard extends Component<DashboardWithStylesProps, DashboardState> {
163
164
} )
164
165
165
166
Actions . refresh ( )
167
+
168
+ this . convertThreadAndRedirectToBot ( )
166
169
}
167
170
168
171
componentWillUnmount ( ) {
@@ -212,6 +215,24 @@ class Dashboard extends Component<DashboardWithStylesProps, DashboardState> {
212
215
this . setState ( { filterValue : event . target . value } )
213
216
}
214
217
218
+ convertThreadAndRedirectToBot = async ( ) => {
219
+ const cookieName = "pgai_tmp_thread_id=" ;
220
+ const cookies = document . cookie . split ( ';' ) . map ( cookie => cookie . trim ( ) ) ;
221
+ const pgaiTmpThreadId = cookies . find ( cookie => cookie . startsWith ( cookieName ) ) ?. substring ( cookieName . length ) || null ;
222
+
223
+ if ( pgaiTmpThreadId ) {
224
+ try {
225
+ const data = await convertThread ( pgaiTmpThreadId ) ;
226
+ if ( data ?. response ?. final_thread_id ) {
227
+ document . cookie = `${ cookieName } =; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; domain=.${ window . location . hostname . split ( '.' ) . slice ( - 2 ) . join ( '.' ) } ` ;
228
+ this . props . history . push ( `demo/bot/${ data . response . final_thread_id } ` ) ;
229
+ }
230
+ } catch ( error ) {
231
+ console . error ( 'Error converting thread:' , error ) ;
232
+ }
233
+ }
234
+ }
235
+
215
236
render ( ) {
216
237
const renderProjects = this . props . onlyProjects
217
238
0 commit comments