@aslaluroba/help-center-react 3.0.1 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +13 -53
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +13 -53
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/ui/help-center.tsx +4 -10
- package/src/ui/help-popup.tsx +11 -44
package/package.json
CHANGED
package/src/ui/help-center.tsx
CHANGED
|
@@ -78,7 +78,7 @@ export function HelpCenter({
|
|
|
78
78
|
setAssistantStatus('idle');
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
-
const handleEndChat = async (
|
|
81
|
+
const handleEndChat = async () => {
|
|
82
82
|
if (!sessionId || !selectedOption) return;
|
|
83
83
|
|
|
84
84
|
try {
|
|
@@ -98,9 +98,7 @@ export function HelpCenter({
|
|
|
98
98
|
setMessages([]);
|
|
99
99
|
|
|
100
100
|
setIsReviewDialogOpen(true);
|
|
101
|
-
|
|
102
|
-
handleStartChat(option);
|
|
103
|
-
}
|
|
101
|
+
|
|
104
102
|
} catch (error) {
|
|
105
103
|
console.error('Error ending chat:', error);
|
|
106
104
|
setError('Failed to end chat session');
|
|
@@ -121,8 +119,7 @@ export function HelpCenter({
|
|
|
121
119
|
const response = await apiRequest(`Client/ClientChatSession/${reviewSessionId}/review`, 'POST', payload);
|
|
122
120
|
if (!response.ok) throw new Error('Failed to send chat review');
|
|
123
121
|
|
|
124
|
-
|
|
125
|
-
setReviewSessionId(null);
|
|
122
|
+
handleCloseChatReview()
|
|
126
123
|
} catch (error) {
|
|
127
124
|
console.error('Error sending chat review:', error);
|
|
128
125
|
setError('Failed to send chat review');
|
|
@@ -139,9 +136,6 @@ export function HelpCenter({
|
|
|
139
136
|
};
|
|
140
137
|
|
|
141
138
|
const startNewChatSession = async (option: Option) => {
|
|
142
|
-
if (isAblyConnected || sessionId) {
|
|
143
|
-
handleEndChat();
|
|
144
|
-
}
|
|
145
139
|
|
|
146
140
|
try {
|
|
147
141
|
setStatus('loading');
|
|
@@ -346,7 +340,7 @@ export function HelpCenter({
|
|
|
346
340
|
showHelpScreen={showHelpScreen}
|
|
347
341
|
/>
|
|
348
342
|
)}
|
|
349
|
-
{isOpen && !!isReviewDialogOpen && (
|
|
343
|
+
{isOpen && !!isReviewDialogOpen && reviewSessionId && (
|
|
350
344
|
<ReviewDialog handleSubmit={handleSendChatReview} onClose={handleCloseChatReview} />
|
|
351
345
|
)}
|
|
352
346
|
</div>
|
package/src/ui/help-popup.tsx
CHANGED
|
@@ -121,61 +121,28 @@ export function HelpPopup({
|
|
|
121
121
|
setEndChatConfirmation(false);
|
|
122
122
|
}, []);
|
|
123
123
|
|
|
124
|
-
const handleEndAndStartNewChat =
|
|
124
|
+
const handleEndAndStartNewChat = async () => {
|
|
125
125
|
if (tempSelectedOption) {
|
|
126
126
|
setStartNewChatConfirmation(false);
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
await onEndChat();
|
|
131
|
-
|
|
132
|
-
// Wait for sessionId to be cleared (indicating the session is fully closed)
|
|
133
|
-
// We'll use a polling mechanism to wait for the state to update
|
|
134
|
-
const maxAttempts = 50; // 5 seconds max wait time
|
|
135
|
-
let attempts = 0;
|
|
136
|
-
|
|
137
|
-
while (sessionId && attempts < maxAttempts) {
|
|
138
|
-
await new Promise((resolve) => setTimeout(resolve, 100)); // Wait 100ms
|
|
139
|
-
attempts++;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// Only start new chat after current session is fully closed
|
|
143
|
-
if (!sessionId) {
|
|
144
|
-
setShowChat(true);
|
|
145
|
-
onStartChat(tempSelectedOption);
|
|
146
|
-
setSelectedOption(tempSelectedOption);
|
|
147
|
-
} else {
|
|
148
|
-
console.warn('Session did not close properly, but proceeding with new chat');
|
|
128
|
+
await handleEndChat()
|
|
129
|
+
.then(() => {
|
|
149
130
|
setShowChat(true);
|
|
150
131
|
onStartChat(tempSelectedOption);
|
|
151
132
|
setSelectedOption(tempSelectedOption);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
setShowChat(true);
|
|
157
|
-
onStartChat(tempSelectedOption);
|
|
158
|
-
setSelectedOption(tempSelectedOption);
|
|
159
|
-
} finally {
|
|
160
|
-
setTempSelectedOption(null);
|
|
161
|
-
}
|
|
133
|
+
})
|
|
134
|
+
.finally(() => {
|
|
135
|
+
setTempSelectedOption(null);
|
|
136
|
+
})
|
|
162
137
|
}
|
|
163
|
-
}
|
|
164
|
-
onEndChat,
|
|
165
|
-
onStartChat,
|
|
166
|
-
setSelectedOption,
|
|
167
|
-
setTempSelectedOption,
|
|
168
|
-
tempSelectedOption,
|
|
169
|
-
setStartNewChatConfirmation,
|
|
170
|
-
sessionId,
|
|
171
|
-
]);
|
|
138
|
+
};
|
|
172
139
|
|
|
173
|
-
const handleEndChat =
|
|
140
|
+
const handleEndChat = async () => {
|
|
174
141
|
setEndChatConfirmation(false);
|
|
175
|
-
onEndChat();
|
|
142
|
+
await onEndChat();
|
|
176
143
|
setShowChat(false);
|
|
177
144
|
setSelectedOption(null);
|
|
178
|
-
}
|
|
145
|
+
};
|
|
179
146
|
|
|
180
147
|
const handleShowActiveChat = useCallback(() => {
|
|
181
148
|
setShowChat(true);
|