@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/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"main": "dist/index.js",
|
|
4
4
|
"module": "dist/index.esm.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
|
-
"version": "3.0.
|
|
6
|
+
"version": "3.0.3",
|
|
7
7
|
"description": "BabylAI Help Center Widget for React and Next.js",
|
|
8
8
|
"private": false,
|
|
9
9
|
"exports": {
|
|
@@ -65,13 +65,13 @@
|
|
|
65
65
|
"@ably/chat": "^0.8.0",
|
|
66
66
|
"@microsoft/signalr": "^7.0.14",
|
|
67
67
|
"ably": "^2.9.0",
|
|
68
|
-
"axios": "^1.
|
|
68
|
+
"axios": "^1.10.0",
|
|
69
69
|
"class-variance-authority": "^0.7.1"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@babel/core": "^7.
|
|
73
|
-
"@babel/preset-env": "^7.
|
|
74
|
-
"@babel/preset-react": "^7.
|
|
72
|
+
"@babel/core": "^7.27.4",
|
|
73
|
+
"@babel/preset-env": "^7.27.2",
|
|
74
|
+
"@babel/preset-react": "^7.27.1",
|
|
75
75
|
"@rollup/plugin-alias": "^5.1.1",
|
|
76
76
|
"@rollup/plugin-babel": "^6.0.4",
|
|
77
77
|
"@rollup/plugin-commonjs": "^21.1.0",
|
|
@@ -85,23 +85,23 @@
|
|
|
85
85
|
"@types/hast": "^3.0.4",
|
|
86
86
|
"@types/node": "^16.18.126",
|
|
87
87
|
"@types/react": "^17.0.83",
|
|
88
|
-
"autoprefixer": "^10.4.
|
|
88
|
+
"autoprefixer": "^10.4.21",
|
|
89
89
|
"babel-loader": "^10.0.0",
|
|
90
90
|
"clsx": "^2.1.1",
|
|
91
91
|
"concurrently": "^9.1.2",
|
|
92
92
|
"i18next": "^25.2.1",
|
|
93
|
-
"postcss": "^8.
|
|
94
|
-
"react-i18next": "^15.5.
|
|
93
|
+
"postcss": "^8.5.6",
|
|
94
|
+
"react-i18next": "^15.5.3",
|
|
95
95
|
"react-markdown": "^10.1.0",
|
|
96
96
|
"rimraf": "^6.0.1",
|
|
97
97
|
"rollup": "^2.79.2",
|
|
98
98
|
"rollup-plugin-postcss": "^4.0.2",
|
|
99
|
-
"tailwind-merge": "^3.3.
|
|
99
|
+
"tailwind-merge": "^3.3.1",
|
|
100
100
|
"tailwindcss": "^3.3.2",
|
|
101
101
|
"tailwindcss-animate": "^1.0.7",
|
|
102
102
|
"tailwindcss-rtl": "^0.9.0",
|
|
103
103
|
"tslib": "^2.8.1",
|
|
104
|
-
"typescript": "^5.
|
|
104
|
+
"typescript": "^5.8.3",
|
|
105
105
|
"webpack": "^5.99.9"
|
|
106
106
|
},
|
|
107
107
|
"publishConfig": {
|
package/src/locales/ar.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"homeSdk": {
|
|
2
3
|
"chatTitle": "تحدث مع",
|
|
3
4
|
"tryBabylAi": "جرّب Babyl AI مجانًا 🎉",
|
|
4
5
|
"contactSdk": "تواصل معنا، دعنا نتحدث!",
|
|
@@ -9,22 +10,25 @@
|
|
|
9
10
|
"endChat": "إنهاء المحادثة",
|
|
10
11
|
"needAssistance": "هل تحتاج مساعدة؟ لاتردد في اخباري اضغط هنا",
|
|
11
12
|
"placeholder": "اكتب سؤالك هنا",
|
|
13
|
+
|
|
12
14
|
"ReviewDialog": {
|
|
13
15
|
"title": "أضف تقييمك",
|
|
14
16
|
"description": "نحن نقدر ملاحظاتك! يُرجى تخصيص لحظة لتقييم تجربتك ومشاركة آرائك في قسم التعليقات أدناه. يساعدنا تقييمك في تحسين خدماتنا ويساعد المستخدمين الآخرين في اتخاذ قرارات مستنيرة. شكرًا لك!",
|
|
15
17
|
"rating_label": "التقييم:",
|
|
16
18
|
"comment_label": "التعليق:",
|
|
19
|
+
"comment_placeholder": "اكتب تعليقك هنا...",
|
|
17
20
|
"submit_button": "إرسال التقييم",
|
|
18
21
|
"comment_error": "يجب أن يكون التعليق بين 10 و500 حرف.",
|
|
19
22
|
"rating_error": "يجب أن يكون التقييم بين 1 و5.",
|
|
20
23
|
"skip_button": "تخطي"
|
|
21
24
|
},
|
|
22
25
|
"ConfirmationModal": {
|
|
23
|
-
"title"
|
|
24
|
-
"message"
|
|
26
|
+
"title": "تأكيد",
|
|
27
|
+
"message": "هل أنت متأكد أنك تريد إنهاء المحادثة؟",
|
|
25
28
|
"confirmation_button": "إنهاء",
|
|
26
|
-
"cancel_button": "إلغاء"
|
|
29
|
+
"cancel_button": "إلغاء",
|
|
30
|
+
"endAndStartNewChatTitle": "إنهاء وبدء محادثة جديدة",
|
|
31
|
+
"endAndStartNewChatMessage": "هل أنت متأكد أنك تريد إنهاء هذه المحادثة وبدء محادثة جديدة؟"
|
|
27
32
|
}
|
|
28
|
-
|
|
29
33
|
}
|
|
30
|
-
}
|
|
34
|
+
}
|
package/src/locales/en.json
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"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!",
|
|
17
17
|
"rating_label": "Rating:",
|
|
18
18
|
"comment_label": "Comment:",
|
|
19
|
+
"comment_placeholder": "Write your comment here...",
|
|
19
20
|
"submit_button": "Submit Review",
|
|
20
21
|
"comment_error": "Comment must be between 10 and 500 characters.",
|
|
21
22
|
"rating_error": "Rating must be between 1 and 5.",
|
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);
|
|
@@ -75,7 +75,7 @@ const ReviewDialog: React.FC<ReviewDialogProps> = (props) => {
|
|
|
75
75
|
id='comment'
|
|
76
76
|
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"
|
|
77
77
|
rows={4}
|
|
78
|
-
placeholder=
|
|
78
|
+
placeholder={t('homeSdk.ReviewDialog.comment_placeholder')}
|
|
79
79
|
value={comment}
|
|
80
80
|
onChange={(e) => handleCommentChange(e.target.value)}
|
|
81
81
|
/>
|