@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.js
CHANGED
|
@@ -294,6 +294,7 @@ var homeSdk$1 = {
|
|
|
294
294
|
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!",
|
|
295
295
|
rating_label: "Rating:",
|
|
296
296
|
comment_label: "Comment:",
|
|
297
|
+
comment_placeholder: "Write your comment here...",
|
|
297
298
|
submit_button: "Submit Review",
|
|
298
299
|
comment_error: "Comment must be between 10 and 500 characters.",
|
|
299
300
|
rating_error: "Rating must be between 1 and 5.",
|
|
@@ -328,6 +329,7 @@ var homeSdk = {
|
|
|
328
329
|
description: "نحن نقدر ملاحظاتك! يُرجى تخصيص لحظة لتقييم تجربتك ومشاركة آرائك في قسم التعليقات أدناه. يساعدنا تقييمك في تحسين خدماتنا ويساعد المستخدمين الآخرين في اتخاذ قرارات مستنيرة. شكرًا لك!",
|
|
329
330
|
rating_label: "التقييم:",
|
|
330
331
|
comment_label: "التعليق:",
|
|
332
|
+
comment_placeholder: "اكتب تعليقك هنا...",
|
|
331
333
|
submit_button: "إرسال التقييم",
|
|
332
334
|
comment_error: "يجب أن يكون التعليق بين 10 و500 حرف.",
|
|
333
335
|
rating_error: "يجب أن يكون التقييم بين 1 و5.",
|
|
@@ -337,7 +339,9 @@ var homeSdk = {
|
|
|
337
339
|
title: "تأكيد",
|
|
338
340
|
message: "هل أنت متأكد أنك تريد إنهاء المحادثة؟",
|
|
339
341
|
confirmation_button: "إنهاء",
|
|
340
|
-
cancel_button: "إلغاء"
|
|
342
|
+
cancel_button: "إلغاء",
|
|
343
|
+
endAndStartNewChatTitle: "إنهاء وبدء محادثة جديدة",
|
|
344
|
+
endAndStartNewChatMessage: "هل أنت متأكد أنك تريد إنهاء هذه المحادثة وبدء محادثة جديدة؟"
|
|
341
345
|
}
|
|
342
346
|
};
|
|
343
347
|
var ar = {
|
|
@@ -427,7 +431,7 @@ const ReviewDialog = (props) => {
|
|
|
427
431
|
React__default["default"].createElement("span", { className: `babylai-text-sm babylai-text-red-500 transition-opacity duration-300 ${error.rating ? 'opacity-100' : 'opacity-0'}` }, error.rating)),
|
|
428
432
|
React__default["default"].createElement("div", { className: "babylai-flex babylai-flex-col babylai-gap-2" },
|
|
429
433
|
React__default["default"].createElement("label", { htmlFor: 'comment', className: "babylai-text-base babylai-font-medium dark:babylai-text-white" }, t('homeSdk.ReviewDialog.comment_label')),
|
|
430
|
-
React__default["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:
|
|
434
|
+
React__default["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) }),
|
|
431
435
|
React__default["default"].createElement("span", { className: `babylai-text-sm babylai-text-red-500 transition-opacity duration-300 ${error.comment ? 'opacity-100' : 'opacity-0'}` }, error.comment))),
|
|
432
436
|
React__default["default"].createElement("footer", { className: "babylai-flex babylai-justify-between babylai-gap-4 babylai-border-t babylai-pt-4" },
|
|
433
437
|
React__default["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')),
|
|
@@ -11282,59 +11286,26 @@ function HelpPopup({ onClose, helpScreen, status, error, onStartChat, onSendMess
|
|
|
11282
11286
|
const hideEndChatConfirmation = React.useCallback(() => {
|
|
11283
11287
|
setEndChatConfirmation(false);
|
|
11284
11288
|
}, []);
|
|
11285
|
-
const handleEndAndStartNewChat =
|
|
11289
|
+
const handleEndAndStartNewChat = async () => {
|
|
11286
11290
|
if (tempSelectedOption) {
|
|
11287
11291
|
setStartNewChatConfirmation(false);
|
|
11288
|
-
|
|
11289
|
-
|
|
11290
|
-
await onEndChat();
|
|
11291
|
-
// Wait for sessionId to be cleared (indicating the session is fully closed)
|
|
11292
|
-
// We'll use a polling mechanism to wait for the state to update
|
|
11293
|
-
const maxAttempts = 50; // 5 seconds max wait time
|
|
11294
|
-
let attempts = 0;
|
|
11295
|
-
while (sessionId && attempts < maxAttempts) {
|
|
11296
|
-
await new Promise((resolve) => setTimeout(resolve, 100)); // Wait 100ms
|
|
11297
|
-
attempts++;
|
|
11298
|
-
}
|
|
11299
|
-
// Only start new chat after current session is fully closed
|
|
11300
|
-
if (!sessionId) {
|
|
11301
|
-
setShowChat(true);
|
|
11302
|
-
onStartChat(tempSelectedOption);
|
|
11303
|
-
setSelectedOption(tempSelectedOption);
|
|
11304
|
-
}
|
|
11305
|
-
else {
|
|
11306
|
-
console.warn('Session did not close properly, but proceeding with new chat');
|
|
11307
|
-
setShowChat(true);
|
|
11308
|
-
onStartChat(tempSelectedOption);
|
|
11309
|
-
setSelectedOption(tempSelectedOption);
|
|
11310
|
-
}
|
|
11311
|
-
}
|
|
11312
|
-
catch (error) {
|
|
11313
|
-
console.error('Error ending current chat:', error);
|
|
11314
|
-
// Even if ending fails, try to start new chat
|
|
11292
|
+
await handleEndChat()
|
|
11293
|
+
.then(() => {
|
|
11315
11294
|
setShowChat(true);
|
|
11316
11295
|
onStartChat(tempSelectedOption);
|
|
11317
11296
|
setSelectedOption(tempSelectedOption);
|
|
11318
|
-
}
|
|
11319
|
-
|
|
11297
|
+
})
|
|
11298
|
+
.finally(() => {
|
|
11320
11299
|
setTempSelectedOption(null);
|
|
11321
|
-
}
|
|
11300
|
+
});
|
|
11322
11301
|
}
|
|
11323
|
-
}
|
|
11324
|
-
|
|
11325
|
-
onStartChat,
|
|
11326
|
-
setSelectedOption,
|
|
11327
|
-
setTempSelectedOption,
|
|
11328
|
-
tempSelectedOption,
|
|
11329
|
-
setStartNewChatConfirmation,
|
|
11330
|
-
sessionId,
|
|
11331
|
-
]);
|
|
11332
|
-
const handleEndChat = React.useCallback(() => {
|
|
11302
|
+
};
|
|
11303
|
+
const handleEndChat = async () => {
|
|
11333
11304
|
setEndChatConfirmation(false);
|
|
11334
|
-
onEndChat();
|
|
11305
|
+
await onEndChat();
|
|
11335
11306
|
setShowChat(false);
|
|
11336
11307
|
setSelectedOption(null);
|
|
11337
|
-
}
|
|
11308
|
+
};
|
|
11338
11309
|
const handleShowActiveChat = React.useCallback(() => {
|
|
11339
11310
|
setShowChat(true);
|
|
11340
11311
|
}, []);
|
|
@@ -11447,7 +11418,7 @@ function HelpCenter({ helpScreenId, user, showArrow = true, language = 'en', mes
|
|
|
11447
11418
|
});
|
|
11448
11419
|
setAssistantStatus('idle');
|
|
11449
11420
|
};
|
|
11450
|
-
const handleEndChat = async (
|
|
11421
|
+
const handleEndChat = async () => {
|
|
11451
11422
|
if (!sessionId || !selectedOption)
|
|
11452
11423
|
return;
|
|
11453
11424
|
try {
|
|
@@ -11464,9 +11435,6 @@ function HelpCenter({ helpScreenId, user, showArrow = true, language = 'en', mes
|
|
|
11464
11435
|
setSelectedOption(null);
|
|
11465
11436
|
setMessages([]);
|
|
11466
11437
|
setIsReviewDialogOpen(true);
|
|
11467
|
-
if (option) {
|
|
11468
|
-
handleStartChat(option);
|
|
11469
|
-
}
|
|
11470
11438
|
}
|
|
11471
11439
|
catch (error) {
|
|
11472
11440
|
console.error('Error ending chat:', error);
|
|
@@ -11486,8 +11454,7 @@ function HelpCenter({ helpScreenId, user, showArrow = true, language = 'en', mes
|
|
|
11486
11454
|
const response = await apiRequest(`Client/ClientChatSession/${reviewSessionId}/review`, 'POST', payload);
|
|
11487
11455
|
if (!response.ok)
|
|
11488
11456
|
throw new Error('Failed to send chat review');
|
|
11489
|
-
|
|
11490
|
-
setReviewSessionId(null);
|
|
11457
|
+
handleCloseChatReview();
|
|
11491
11458
|
}
|
|
11492
11459
|
catch (error) {
|
|
11493
11460
|
console.error('Error sending chat review:', error);
|
|
@@ -11503,9 +11470,6 @@ function HelpCenter({ helpScreenId, user, showArrow = true, language = 'en', mes
|
|
|
11503
11470
|
};
|
|
11504
11471
|
const startNewChatSession = async (option) => {
|
|
11505
11472
|
var _a;
|
|
11506
|
-
if (isAblyConnected || sessionId) {
|
|
11507
|
-
handleEndChat();
|
|
11508
|
-
}
|
|
11509
11473
|
try {
|
|
11510
11474
|
setStatus('loading');
|
|
11511
11475
|
setError('');
|
|
@@ -11644,7 +11608,7 @@ function HelpCenter({ helpScreenId, user, showArrow = true, language = 'en', mes
|
|
|
11644
11608
|
showArrowAnimation && !isOpen && (React__default["default"].createElement(FloatingMessage, { onClose: handleCloseArrowAnimation, message: messageLabel || t('homeSdk.needAssistance') })),
|
|
11645
11609
|
React__default["default"].createElement(HelpButton, { onClick: handleTogglePopup }),
|
|
11646
11610
|
isOpen && (React__default["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 })),
|
|
11647
|
-
isOpen && !!isReviewDialogOpen && (React__default["default"].createElement(ReviewDialog, { handleSubmit: handleSendChatReview, onClose: handleCloseChatReview }))));
|
|
11611
|
+
isOpen && !!isReviewDialogOpen && reviewSessionId && (React__default["default"].createElement(ReviewDialog, { handleSubmit: handleSendChatReview, onClose: handleCloseChatReview }))));
|
|
11648
11612
|
}
|
|
11649
11613
|
|
|
11650
11614
|
class ApiService {
|