@aslaluroba/help-center-react 3.0.1 → 3.0.3
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 +19 -55
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +19 -55
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
- package/src/locales/ar.json +10 -6
- package/src/locales/en.json +1 -0
- package/src/ui/help-center.tsx +4 -10
- package/src/ui/help-popup.tsx +11 -44
- package/src/ui/review-dialog/index.tsx +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -265,6 +265,7 @@ var homeSdk$1 = {
|
|
|
265
265
|
description: "We appreciate your feedback! Please take a moment to rate your experience and share your thoughts in the comment section below. Your review helps us improve our services and assists other users in making informed decisions. Thank you!",
|
|
266
266
|
rating_label: "Rating:",
|
|
267
267
|
comment_label: "Comment:",
|
|
268
|
+
comment_placeholder: "Write your comment here...",
|
|
268
269
|
submit_button: "Submit Review",
|
|
269
270
|
comment_error: "Comment must be between 10 and 500 characters.",
|
|
270
271
|
rating_error: "Rating must be between 1 and 5.",
|
|
@@ -299,6 +300,7 @@ var homeSdk = {
|
|
|
299
300
|
description: "نحن نقدر ملاحظاتك! يُرجى تخصيص لحظة لتقييم تجربتك ومشاركة آرائك في قسم التعليقات أدناه. يساعدنا تقييمك في تحسين خدماتنا ويساعد المستخدمين الآخرين في اتخاذ قرارات مستنيرة. شكرًا لك!",
|
|
300
301
|
rating_label: "التقييم:",
|
|
301
302
|
comment_label: "التعليق:",
|
|
303
|
+
comment_placeholder: "اكتب تعليقك هنا...",
|
|
302
304
|
submit_button: "إرسال التقييم",
|
|
303
305
|
comment_error: "يجب أن يكون التعليق بين 10 و500 حرف.",
|
|
304
306
|
rating_error: "يجب أن يكون التقييم بين 1 و5.",
|
|
@@ -308,7 +310,9 @@ var homeSdk = {
|
|
|
308
310
|
title: "تأكيد",
|
|
309
311
|
message: "هل أنت متأكد أنك تريد إنهاء المحادثة؟",
|
|
310
312
|
confirmation_button: "إنهاء",
|
|
311
|
-
cancel_button: "إلغاء"
|
|
313
|
+
cancel_button: "إلغاء",
|
|
314
|
+
endAndStartNewChatTitle: "إنهاء وبدء محادثة جديدة",
|
|
315
|
+
endAndStartNewChatMessage: "هل أنت متأكد أنك تريد إنهاء هذه المحادثة وبدء محادثة جديدة؟"
|
|
312
316
|
}
|
|
313
317
|
};
|
|
314
318
|
var ar = {
|
|
@@ -398,7 +402,7 @@ const ReviewDialog = (props) => {
|
|
|
398
402
|
React__default.createElement("span", { className: `babylai-text-sm babylai-text-red-500 transition-opacity duration-300 ${error.rating ? 'opacity-100' : 'opacity-0'}` }, error.rating)),
|
|
399
403
|
React__default.createElement("div", { className: "babylai-flex babylai-flex-col babylai-gap-2" },
|
|
400
404
|
React__default.createElement("label", { htmlFor: 'comment', className: "babylai-text-base babylai-font-medium dark:babylai-text-white" }, t('homeSdk.ReviewDialog.comment_label')),
|
|
401
|
-
React__default.createElement("textarea", { id: 'comment', className: "babylai-bg-black-white-100 babylai-p-6 babylai-rounded-xl babylai-resize-none dark:babylai-bg-storm-dust-900 dark:babylai-text-white", rows: 4, placeholder:
|
|
405
|
+
React__default.createElement("textarea", { id: 'comment', className: "babylai-bg-black-white-100 babylai-p-6 babylai-rounded-xl babylai-resize-none dark:babylai-bg-storm-dust-900 dark:babylai-text-white", rows: 4, placeholder: t('homeSdk.ReviewDialog.comment_placeholder'), value: comment, onChange: (e) => handleCommentChange(e.target.value) }),
|
|
402
406
|
React__default.createElement("span", { className: `babylai-text-sm babylai-text-red-500 transition-opacity duration-300 ${error.comment ? 'opacity-100' : 'opacity-0'}` }, error.comment))),
|
|
403
407
|
React__default.createElement("footer", { className: "babylai-flex babylai-justify-between babylai-gap-4 babylai-border-t babylai-pt-4" },
|
|
404
408
|
React__default.createElement("button", { className: "babylai-px-4 babylai-py-2 babylai-rounded-lg babylai-bg-gray-200 babylai-text-gray-700 hover:babylai-bg-gray-300 transition-all", onClick: props.onClose }, t('homeSdk.ReviewDialog.skip_button')),
|
|
@@ -11253,59 +11257,26 @@ function HelpPopup({ onClose, helpScreen, status, error, onStartChat, onSendMess
|
|
|
11253
11257
|
const hideEndChatConfirmation = useCallback(() => {
|
|
11254
11258
|
setEndChatConfirmation(false);
|
|
11255
11259
|
}, []);
|
|
11256
|
-
const handleEndAndStartNewChat =
|
|
11260
|
+
const handleEndAndStartNewChat = async () => {
|
|
11257
11261
|
if (tempSelectedOption) {
|
|
11258
11262
|
setStartNewChatConfirmation(false);
|
|
11259
|
-
|
|
11260
|
-
|
|
11261
|
-
await onEndChat();
|
|
11262
|
-
// Wait for sessionId to be cleared (indicating the session is fully closed)
|
|
11263
|
-
// We'll use a polling mechanism to wait for the state to update
|
|
11264
|
-
const maxAttempts = 50; // 5 seconds max wait time
|
|
11265
|
-
let attempts = 0;
|
|
11266
|
-
while (sessionId && attempts < maxAttempts) {
|
|
11267
|
-
await new Promise((resolve) => setTimeout(resolve, 100)); // Wait 100ms
|
|
11268
|
-
attempts++;
|
|
11269
|
-
}
|
|
11270
|
-
// Only start new chat after current session is fully closed
|
|
11271
|
-
if (!sessionId) {
|
|
11272
|
-
setShowChat(true);
|
|
11273
|
-
onStartChat(tempSelectedOption);
|
|
11274
|
-
setSelectedOption(tempSelectedOption);
|
|
11275
|
-
}
|
|
11276
|
-
else {
|
|
11277
|
-
console.warn('Session did not close properly, but proceeding with new chat');
|
|
11278
|
-
setShowChat(true);
|
|
11279
|
-
onStartChat(tempSelectedOption);
|
|
11280
|
-
setSelectedOption(tempSelectedOption);
|
|
11281
|
-
}
|
|
11282
|
-
}
|
|
11283
|
-
catch (error) {
|
|
11284
|
-
console.error('Error ending current chat:', error);
|
|
11285
|
-
// Even if ending fails, try to start new chat
|
|
11263
|
+
await handleEndChat()
|
|
11264
|
+
.then(() => {
|
|
11286
11265
|
setShowChat(true);
|
|
11287
11266
|
onStartChat(tempSelectedOption);
|
|
11288
11267
|
setSelectedOption(tempSelectedOption);
|
|
11289
|
-
}
|
|
11290
|
-
|
|
11268
|
+
})
|
|
11269
|
+
.finally(() => {
|
|
11291
11270
|
setTempSelectedOption(null);
|
|
11292
|
-
}
|
|
11271
|
+
});
|
|
11293
11272
|
}
|
|
11294
|
-
}
|
|
11295
|
-
|
|
11296
|
-
onStartChat,
|
|
11297
|
-
setSelectedOption,
|
|
11298
|
-
setTempSelectedOption,
|
|
11299
|
-
tempSelectedOption,
|
|
11300
|
-
setStartNewChatConfirmation,
|
|
11301
|
-
sessionId,
|
|
11302
|
-
]);
|
|
11303
|
-
const handleEndChat = useCallback(() => {
|
|
11273
|
+
};
|
|
11274
|
+
const handleEndChat = async () => {
|
|
11304
11275
|
setEndChatConfirmation(false);
|
|
11305
|
-
onEndChat();
|
|
11276
|
+
await onEndChat();
|
|
11306
11277
|
setShowChat(false);
|
|
11307
11278
|
setSelectedOption(null);
|
|
11308
|
-
}
|
|
11279
|
+
};
|
|
11309
11280
|
const handleShowActiveChat = useCallback(() => {
|
|
11310
11281
|
setShowChat(true);
|
|
11311
11282
|
}, []);
|
|
@@ -11418,7 +11389,7 @@ function HelpCenter({ helpScreenId, user, showArrow = true, language = 'en', mes
|
|
|
11418
11389
|
});
|
|
11419
11390
|
setAssistantStatus('idle');
|
|
11420
11391
|
};
|
|
11421
|
-
const handleEndChat = async (
|
|
11392
|
+
const handleEndChat = async () => {
|
|
11422
11393
|
if (!sessionId || !selectedOption)
|
|
11423
11394
|
return;
|
|
11424
11395
|
try {
|
|
@@ -11435,9 +11406,6 @@ function HelpCenter({ helpScreenId, user, showArrow = true, language = 'en', mes
|
|
|
11435
11406
|
setSelectedOption(null);
|
|
11436
11407
|
setMessages([]);
|
|
11437
11408
|
setIsReviewDialogOpen(true);
|
|
11438
|
-
if (option) {
|
|
11439
|
-
handleStartChat(option);
|
|
11440
|
-
}
|
|
11441
11409
|
}
|
|
11442
11410
|
catch (error) {
|
|
11443
11411
|
console.error('Error ending chat:', error);
|
|
@@ -11457,8 +11425,7 @@ function HelpCenter({ helpScreenId, user, showArrow = true, language = 'en', mes
|
|
|
11457
11425
|
const response = await apiRequest(`Client/ClientChatSession/${reviewSessionId}/review`, 'POST', payload);
|
|
11458
11426
|
if (!response.ok)
|
|
11459
11427
|
throw new Error('Failed to send chat review');
|
|
11460
|
-
|
|
11461
|
-
setReviewSessionId(null);
|
|
11428
|
+
handleCloseChatReview();
|
|
11462
11429
|
}
|
|
11463
11430
|
catch (error) {
|
|
11464
11431
|
console.error('Error sending chat review:', error);
|
|
@@ -11474,9 +11441,6 @@ function HelpCenter({ helpScreenId, user, showArrow = true, language = 'en', mes
|
|
|
11474
11441
|
};
|
|
11475
11442
|
const startNewChatSession = async (option) => {
|
|
11476
11443
|
var _a;
|
|
11477
|
-
if (isAblyConnected || sessionId) {
|
|
11478
|
-
handleEndChat();
|
|
11479
|
-
}
|
|
11480
11444
|
try {
|
|
11481
11445
|
setStatus('loading');
|
|
11482
11446
|
setError('');
|
|
@@ -11615,7 +11579,7 @@ function HelpCenter({ helpScreenId, user, showArrow = true, language = 'en', mes
|
|
|
11615
11579
|
showArrowAnimation && !isOpen && (React__default.createElement(FloatingMessage, { onClose: handleCloseArrowAnimation, message: messageLabel || t('homeSdk.needAssistance') })),
|
|
11616
11580
|
React__default.createElement(HelpButton, { onClick: handleTogglePopup }),
|
|
11617
11581
|
isOpen && (React__default.createElement(HelpPopup, { isOpen: isOpen, onClose: () => setIsOpen(false), helpScreen: helpScreenData, status: status, error: error, user: user, onStartChat: handleStartChat, onSendMessage: handleSendMessage, onEndChat: handleEndChat, messages: messages, needsAgent: needsAgent, assistantStatus: assistantStatus, sessionId: sessionId, isChatClosed: isChatClosed, isAblyConnected: isAblyConnected, selectedOption: selectedOption, setSelectedOption: setSelectedOption, showHelpScreen: showHelpScreen })),
|
|
11618
|
-
isOpen && !!isReviewDialogOpen && (React__default.createElement(ReviewDialog, { handleSubmit: handleSendChatReview, onClose: handleCloseChatReview }))));
|
|
11582
|
+
isOpen && !!isReviewDialogOpen && reviewSessionId && (React__default.createElement(ReviewDialog, { handleSubmit: handleSendChatReview, onClose: handleCloseChatReview }))));
|
|
11619
11583
|
}
|
|
11620
11584
|
|
|
11621
11585
|
class ApiService {
|