@@ -228,45 +228,17 @@ export const fetchAvailableModels = createAsyncThunk(
228
228
}
229
229
) ;
230
230
231
- // Add this helper function to generate a UUID
232
- const generateSessionId = ( ) => {
233
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx' . replace ( / [ x y ] / g, function ( c ) {
234
- const r = Math . random ( ) * 16 | 0 ,
235
- v = c == 'x' ? r : ( r & 0x3 | 0x8 ) ;
236
- return v . toString ( 16 ) ;
237
- } ) ;
238
- } ;
239
-
240
- // Create or retrieve a session ID from local storage
241
- const getOrCreateSessionId = ( ) => {
242
- let sessionId = localStorage . getItem ( 'app_session_id' ) ;
243
- if ( ! sessionId ) {
244
- sessionId = generateSessionId ( ) ;
245
- localStorage . setItem ( 'app_session_id' , sessionId ) ;
246
- }
247
- return sessionId ;
248
- } ;
249
-
250
- // Update your fetch function to include the session ID in the request
251
231
export const fetchSessionId = createAsyncThunk (
252
- "dataFormulatorSlice/fetchSessionId" ,
253
- async ( ) => {
254
- const sessionId = getOrCreateSessionId ( ) ;
255
-
256
- const response = await fetch ( getUrls ( ) . SESSION_ID , {
257
- method : 'GET' ,
258
- headers : {
259
- 'Content-Type' : 'application/json' ,
260
- 'X-Session-ID' : sessionId // Pass session ID as a custom header
261
- }
262
- } ) ;
263
-
264
- const data = await response . json ( ) ;
265
- return {
266
- ...data ,
267
- session_id : sessionId // Ensure we return the session ID
268
- } ;
269
- }
232
+ "dataFormulatorSlice/fetchSessionId" ,
233
+ async ( ) => {
234
+ const response = await fetch ( getUrls ( ) . SESSION_ID , {
235
+ method : 'GET' ,
236
+ headers : {
237
+ 'Content-Type' : 'application/json' ,
238
+ }
239
+ } ) ;
240
+ return response . json ( ) ;
241
+ }
270
242
) ;
271
243
272
244
export const dataFormulatorSlice = createSlice ( {
@@ -731,8 +703,6 @@ export const dataFormulatorSlice = createSlice({
731
703
console . log ( action . payload ) ;
732
704
} )
733
705
. addCase ( fetchSessionId . fulfilled , ( state , action ) => {
734
- console . log ( ">>> fetchSessionId <<<" )
735
- console . log ( action . payload )
736
706
state . sessionId = action . payload . session_id ;
737
707
} )
738
708
} ,
0 commit comments