@@ -10,18 +10,11 @@ import useUpdateHeader from '../hooks/useUpdateHeader';
10
10
import useRingEffect from '../hooks/useRingEffect' ;
11
11
import { DEFAULT_CONFIG } from '../config/constants' ;
12
12
13
- /**
14
- * Generate a unique session ID
15
- * @returns {string } A unique session identifier
16
- */
13
+
17
14
const generateSessionId = ( ) => {
18
15
return `qa_bot_session_${ uuidv4 ( ) } ` ;
19
16
} ;
20
17
21
- /**
22
- * Get or create a session ID from localStorage
23
- * @returns {string } A session identifier
24
- */
25
18
const getOrCreateSessionId = ( ) => {
26
19
// Check if we already have a session ID in localStorage
27
20
for ( let i = 0 ; i < localStorage . length ; i ++ ) {
@@ -33,12 +26,19 @@ const getOrCreateSessionId = () => {
33
26
}
34
27
}
35
28
}
36
-
37
- // No existing session found, generate a new one
38
29
const newSessionId = generateSessionId ( ) ;
39
30
localStorage . setItem ( newSessionId , newSessionId ) ;
40
31
return newSessionId ;
41
32
} ;
33
+
34
+ const buildWelcomeMessage = ( isLoggedIn , welcomeMessage ) => {
35
+ if ( isLoggedIn ) {
36
+ return welcomeMessage || DEFAULT_CONFIG . WELCOME_MESSAGE ;
37
+ } else {
38
+ return DEFAULT_CONFIG . WELCOME_MESSAGE_LOGGED_OUT ;
39
+ }
40
+ }
41
+
42
42
/**
43
43
* Q&A Bot Component (Controlled)
44
44
*
@@ -53,15 +53,6 @@ const getOrCreateSessionId = () => {
53
53
* @param {string } [props.welcome='Hello! What can I help you with?'] - Welcome message
54
54
* @returns {JSX.Element }
55
55
*/
56
-
57
- const buildWelcomeMessage = ( isLoggedIn , welcomeMessage ) => {
58
- if ( isLoggedIn ) {
59
- return welcomeMessage || DEFAULT_CONFIG . WELCOME_MESSAGE ;
60
- } else {
61
- return DEFAULT_CONFIG . WELCOME_MESSAGE_LOGGED_OUT ;
62
- }
63
- }
64
-
65
56
const QABot = React . forwardRef ( ( props , botRef ) => {
66
57
const {
67
58
apiKey,
@@ -120,10 +111,8 @@ const QABot = React.forwardRef((props, botRef) => {
120
111
isLoggedIn : isBotLoggedIn
121
112
} ) ;
122
113
123
- // Use the AI query handling hook
124
114
const handleQuery = useHandleAIQuery ( finalApiKey , sessionId , setCurrentQueryId ) ;
125
115
126
- // Use the chat flow hook
127
116
const flow = useChatFlow ( {
128
117
welcomeMessage,
129
118
isBotLoggedIn,
0 commit comments