shopify-chatbot-widget 1.0.8 → 1.0.10

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.
Files changed (46) hide show
  1. package/.env.development +2 -0
  2. package/dist/jaweb-chatbot.css +1 -1
  3. package/dist/jaweb-chatbot.iife.js +192 -599
  4. package/home.html +1 -1
  5. package/jawebDirect.js +1 -1
  6. package/package.json +1 -1
  7. package/src/App.tsx +9 -0
  8. package/src/Chatbot/Chatbot.css +193 -113
  9. package/src/Chatbot/Chatbot.tsx +26 -19
  10. package/src/Chatbot/components/Cart/Index.tsx +10 -8
  11. package/src/Chatbot/components/ChatInput.tsx +11 -11
  12. package/src/Chatbot/components/Home/Home.css +456 -0
  13. package/src/Chatbot/components/Home/Home.tsx +293 -0
  14. package/src/Chatbot/components/Messages/Addcart.tsx +1 -1
  15. package/src/Chatbot/components/Messages/AssistantMesage.tsx +78 -37
  16. package/src/Chatbot/components/Messages/CardSwiper.tsx +1 -1
  17. package/src/Chatbot/components/Messages/Carousel/CardSwiper.tsx +87 -92
  18. package/src/Chatbot/components/Messages/Carousel/ProductSwiper.css +361 -0
  19. package/src/Chatbot/components/Messages/Carousel/TryOn.tsx +2 -2
  20. package/src/Chatbot/components/Messages/ChatMessages.css +32 -1
  21. package/src/Chatbot/components/Messages/ChatMessages.tsx +21 -38
  22. package/src/Chatbot/components/Messages/OrderCard.css +177 -0
  23. package/src/Chatbot/components/Messages/OrderCard.tsx +120 -0
  24. package/src/Chatbot/components/Messages/ProductCard.css +1 -1
  25. package/src/Chatbot/components/Messages/Support.tsx +311 -118
  26. package/src/Chatbot/components/Messages/Typing.css +31 -35
  27. package/src/Chatbot/components/Messages/Typing.tsx +19 -18
  28. package/src/Chatbot/components/Messenger/Messenger.tsx +67 -14
  29. package/src/Chatbot/components/Powered.css +26 -28
  30. package/src/Chatbot/components/Powered.tsx +1 -1
  31. package/src/Chatbot/components/Sessions/CreateSession.tsx +12 -10
  32. package/src/Chatbot/components/TryOn/View.tsx +2 -2
  33. package/src/Chatbot/components/VoiceMode.css +247 -0
  34. package/src/Chatbot/components/VoiceMode.tsx +613 -0
  35. package/src/hooks/config.tsx +9 -10
  36. package/src/hooks/useChatbotAPI.tsx +146 -61
  37. package/src/hooks/useChatbotData.tsx +8 -5
  38. package/src/hooks/useSessionMessages.tsx +0 -1
  39. package/src/hooks/useWebsocke.tsx +40 -18
  40. package/src/i18n.tsx +384 -10
  41. package/src/Chatbot/components/Messages/Carousel/CardSwiperSalla.tsx +0 -187
  42. package/src/Chatbot/components/Messages/Carousel/CardSwiperZid.tsx +0 -208
  43. package/src/Chatbot/components/Messages/Carousel/SallaSwiper.css +0 -245
  44. package/src/Chatbot/components/Messages/SallaAssistantMessage.tsx +0 -202
  45. package/src/Chatbot/components/Messages/ZidAssistantMesage.tsx +0 -203
  46. package/src/Chatbot/components/Sessions/RenderList.tsx +0 -519
@@ -1,519 +0,0 @@
1
- import React, { useEffect, useState } from 'react';
2
- import { List, Avatar, Typography, Spin } from 'antd';
3
- import { UserOutlined, LoadingOutlined, CloseOutlined, WhatsAppOutlined, MessageOutlined } from '@ant-design/icons';
4
- import config from '../../../hooks/config';
5
-
6
- const { Text, Title } = Typography;
7
-
8
- type ChatSession = {
9
- id: string;
10
- agentName?: string;
11
- createdAt: string;
12
- isBlurred?: boolean;
13
- agentImage?: string;
14
- };
15
-
16
- type ChatSessionsProps = {
17
- setOpen: (v: boolean) => void;
18
- Opened: boolean;
19
- Phone: string;
20
- chatbotLogo: string;
21
- colorCode?: string;
22
- onNewSession: () => void;
23
- visitorId: string;
24
- onSessionSelect: (sessionId: string, agentName: string, agentImage: string) => void;
25
- };
26
-
27
- const ChatSessions: React.FC<ChatSessionsProps> = ({
28
- chatbotLogo,
29
- colorCode,
30
- onNewSession,
31
- visitorId,
32
- onSessionSelect,
33
- setOpen,
34
- Opened,
35
- Phone,
36
- }) => {
37
- const [sessions, setSessions] = useState<ChatSession[]>([]);
38
- const [loading, setLoading] = useState(true);
39
- const [mounted, setMounted] = useState(false);
40
-
41
- const fetchSessions = async () => {
42
- try {
43
- setLoading(true);
44
- const res = await fetch(
45
- `${config.apiUrl}get-chatlogs-by-ip/?visitor_id=${visitorId}&company_username=${localStorage.getItem('company_username')}`
46
- );
47
- const data = await res.json();
48
-
49
-
50
- const mapped: ChatSession[] = data.map((item: any) => {
51
- const createdDate = new Date(item.date);
52
- const now = new Date();
53
- const diffDays = Math.floor((now.getTime() - createdDate.getTime()) / (1000 * 60 * 60 * 24));
54
-
55
- const isOlderThan5Days = diffDays >= 5;
56
-
57
- return {
58
- id: item.user_session_id,
59
- agentName: item.assignee || 'AI Agent',
60
- createdAt: item.date,
61
- isBlurred: item.closed || isOlderThan5Days,
62
- agentImage: item.assignee_picture,
63
- };
64
- });
65
-
66
- setSessions(mapped);
67
-
68
- } catch (err) {
69
- console.error('Failed to load sessions:', err);
70
- } finally {
71
- setLoading(false);
72
- }
73
- };
74
-
75
-
76
- useEffect(() => {
77
- if (visitorId) {
78
- fetchSessions();
79
- }
80
- setMounted(true);
81
- }, [visitorId]);
82
-
83
- const loadingIcon = <LoadingOutlined style={{ fontSize: 24, color: colorCode || '#7F28F8' }} spin />;
84
- const primaryColor = colorCode || '#7F28F8';
85
-
86
- return (
87
- <>
88
- <style>
89
- {`
90
- @keyframes slideInUp {
91
- from {
92
- opacity: 0;
93
- transform: translateY(30px);
94
- }
95
- to {
96
- opacity: 1;
97
- transform: translateY(0);
98
- }
99
- }
100
-
101
- @keyframes fadeIn {
102
- from {
103
- opacity: 0;
104
- }
105
- to {
106
- opacity: 1;
107
- }
108
- }
109
-
110
- @keyframes slideInRight {
111
- from {
112
- opacity: 0;
113
- transform: translateX(-15px);
114
- }
115
- to {
116
- opacity: 1;
117
- transform: translateX(0);
118
- }
119
- }
120
-
121
- @keyframes scaleIn {
122
- from {
123
- opacity: 0;
124
- transform: scale(0.95);
125
- }
126
- to {
127
- opacity: 1;
128
- transform: scale(1);
129
- }
130
- }
131
-
132
- @keyframes spinnerPulse {
133
- 0%, 100% {
134
- opacity: 1;
135
- transform: scale(1);
136
- }
137
- 50% {
138
- opacity: 0.8;
139
- transform: scale(1.05);
140
- }
141
- }
142
-
143
- .chat-sessions-container {
144
- animation: ${mounted ? 'slideInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1)' : 'none'};
145
- }
146
-
147
- .session-list-item {
148
- transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
149
- position: relative;
150
- overflow: hidden;
151
- }
152
-
153
- .session-list-item::before {
154
- content: '';
155
- position: absolute;
156
- left: 0;
157
- top: 0;
158
- height: 100%;
159
- width: 3px;
160
- background: ${primaryColor};
161
- transform: scaleY(0);
162
- transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
163
- }
164
-
165
- .session-list-item:hover:not(.disabled)::before {
166
- transform: scaleY(1);
167
- }
168
-
169
- .session-list-item:hover:not(.disabled) {
170
- background: linear-gradient(90deg, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0.3) 100%);
171
- backdropFilter: blur(10px);
172
- transform: translateX(4px);
173
- }
174
-
175
- .session-list-item:active:not(.disabled) {
176
- transform: translateX(2px) scale(0.99);
177
- }
178
-
179
- .session-list-item.stagger-1 { animation: slideInRight 0.4s cubic-bezier(0.16, 1, 0.3, 1) 0.05s both; }
180
- .session-list-item.stagger-2 { animation: slideInRight 0.4s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both; }
181
- .session-list-item.stagger-3 { animation: slideInRight 0.4s cubic-bezier(0.16, 1, 0.3, 1) 0.15s both; }
182
- .session-list-item.stagger-4 { animation: slideInRight 0.4s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both; }
183
- .session-list-item.stagger-5 { animation: slideInRight 0.4s cubic-bezier(0.16, 1, 0.3, 1) 0.25s both; }
184
- .session-list-item.stagger-6 { animation: slideInRight 0.4s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both; }
185
-
186
- .avatar-wrapper {
187
- position: relative;
188
- transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
189
- }
190
-
191
- .session-list-item:hover:not(.disabled) .avatar-wrapper {
192
- transform: scale(1.08);
193
- }
194
-
195
- .avatar-wrapper::after {
196
- content: '';
197
- position: absolute;
198
- inset: -2px;
199
- border-radius: 50%;
200
- background: ${primaryColor};
201
- opacity: 0;
202
- filter: blur(8px);
203
- transition: opacity 0.3s ease;
204
- z-index: -1;
205
- }
206
-
207
- .session-list-item:hover:not(.disabled) .avatar-wrapper::after {
208
- opacity: 0.2;
209
- }
210
-
211
- .session-title {
212
- transition: color 0.3s ease;
213
- }
214
-
215
- .session-list-item:hover:not(.disabled) .session-title {
216
- color: ${primaryColor};
217
- }
218
-
219
- .header-section {
220
- animation: fadeIn 0.5s ease 0.2s both;
221
- }
222
-
223
- .close-icon {
224
- transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
225
- cursor: pointer;
226
- }
227
-
228
- .close-icon:hover {
229
- transform: rotate(90deg) scale(1.1);
230
- color: ${primaryColor};
231
- }
232
-
233
- .close-icon:active {
234
- transform: rotate(90deg) scale(0.95);
235
- }
236
-
237
- .action-button {
238
- position: relative;
239
- overflow: hidden;
240
- transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
241
- }
242
-
243
- .action-button::before {
244
- content: '';
245
- position: absolute;
246
- top: 50%;
247
- left: 50%;
248
- width: 0;
249
- height: 0;
250
- border-radius: 50%;
251
- background: rgba(255, 255, 255, 0.3);
252
- transform: translate(-50%, -50%);
253
- transition: width 0.6s ease, height 0.6s ease;
254
- }
255
-
256
- .action-button:active::before {
257
- width: 300px;
258
- height: 300px;
259
- }
260
-
261
- .action-button:hover {
262
- transform: translateY(-2px);
263
- }
264
-
265
- .action-button:active {
266
- transform: translateY(0);
267
- }
268
-
269
- .new-chat-button {
270
- box-shadow: 0 4px 12px rgba(10, 10, 10, 0.25);
271
- }
272
-
273
- .new-chat-button:hover {
274
- box-shadow: 0 6px 20px rgba(10, 10, 10, 0.35);
275
- }
276
-
277
- .whatsapp-button {
278
- box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
279
- }
280
-
281
- .whatsapp-button:hover {
282
- box-shadow: 0 6px 20px rgba(37, 211, 102, 0.45);
283
- transform: translateY(-2px) scale(1.03);
284
- }
285
-
286
- .button-icon {
287
- transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
288
- }
289
-
290
- .action-button:hover .button-icon {
291
- transform: scale(1.1);
292
- }
293
-
294
- .loading-container {
295
- animation: scaleIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
296
- }
297
-
298
- .loading-spinner {
299
- animation: spinnerPulse 2s ease-in-out infinite;
300
- }
301
-
302
- .empty-state {
303
- animation: fadeIn 0.5s ease 0.2s both;
304
- }
305
-
306
- .action-buttons-container {
307
- animation: slideInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both;
308
- }
309
-
310
- .disabled {
311
- pointer-events: none;
312
- }
313
-
314
- .closed-badge {
315
- animation: fadeIn 0.4s ease 0.1s both;
316
- }
317
-
318
- /* Smooth scrollbar */
319
- .sessions-scroll::-webkit-scrollbar {
320
- width: 6px;
321
- }
322
-
323
- .sessions-scroll::-webkit-scrollbar-track {
324
- background: transparent;
325
- }
326
-
327
- .sessions-scroll::-webkit-scrollbar-thumb {
328
- background: ${primaryColor}40;
329
- border-radius: 3px;
330
- transition: background 0.3s ease;
331
- }
332
-
333
- .sessions-scroll::-webkit-scrollbar-thumb:hover {
334
- background: ${primaryColor}60;
335
- }
336
- `}
337
- </style>
338
-
339
- <div
340
- className="chat-sessions-container"
341
- style={{
342
- maxWidth: '100%',
343
- height: '100%',
344
- background: 'rgba(255, 255, 255, 0.7)',
345
- backdropFilter: 'blur(20px) saturate(180%)',
346
- WebkitBackdropFilter: 'blur(20px) saturate(180%)',
347
- border: '1px solid rgba(255, 255, 255, 0.18)',
348
- borderRadius: 8,
349
- overflow: 'hidden',
350
- display: 'flex',
351
- flexDirection: 'column',
352
- paddingTop: 20,
353
- boxShadow: '0 8px 32px 0 rgba(31, 38, 135, 0.1)',
354
- }}
355
- >
356
- <div className="header-section" style={{
357
- padding: '0 16px 10px',
358
- display: 'flex',
359
- background: 'rgba(255, 255, 255, 0.4)',
360
- backdropFilter: 'blur(10px)',
361
- WebkitBackdropFilter: 'blur(10px)',
362
- borderBottom: '1px solid rgba(255, 255, 255, 0.18)',
363
- marginBottom: '8px',
364
- }}>
365
- <Title level={4} style={{ margin: 0 }}>
366
- Conversations
367
- </Title>
368
-
369
- <CloseOutlined
370
- onClick={() => setOpen(!Opened)}
371
- className="close-icon"
372
- style={{ marginLeft: 'auto', fontSize: 16 }}
373
- />
374
- </div>
375
-
376
- <div className="sessions-scroll" style={{ flex: 1, overflowY: 'auto' }}>
377
- {loading ? (
378
- <div className="loading-container" style={{
379
- textAlign: 'center',
380
- padding: '2rem',
381
- background: 'rgba(255, 255, 255, 0.3)',
382
- backdropFilter: 'blur(10px)',
383
- WebkitBackdropFilter: 'blur(10px)',
384
- borderRadius: '12px',
385
- margin: '1rem',
386
- }}>
387
- <Spin indicator={<div className="loading-spinner">{loadingIcon}</div>} />
388
- </div>
389
- ) : sessions.length > 0 ? (
390
- <List
391
- itemLayout="horizontal"
392
- dataSource={sessions}
393
- split={true}
394
- renderItem={(session, index) => (
395
- <List.Item
396
- key={session.id}
397
- className={`session-list-item ${session.isBlurred ? 'disabled' : ''} stagger-${Math.min(index + 1, 6)}`}
398
- onClick={() =>
399
- !session.isBlurred &&
400
- onSessionSelect(session.id, session.agentName || 'Ai Agent', session.agentImage || chatbotLogo)
401
- }
402
- style={{
403
- padding: '12px',
404
- opacity: session.isBlurred ? 0.5 : 1,
405
- cursor: session.isBlurred ? 'not-allowed' : 'pointer',
406
- borderBottom: '1px solid #f0f0f0',
407
- }}
408
- >
409
- <List.Item.Meta
410
- avatar={
411
- <div className="avatar-wrapper">
412
- <Avatar
413
- size="large"
414
- src={session.agentImage || chatbotLogo}
415
- icon={!session.agentImage && !chatbotLogo ? <UserOutlined /> : undefined}
416
- />
417
- </div>
418
- }
419
- title={
420
- <span className="session-title" style={{ fontWeight: 600 }}>
421
- {session.agentName || 'AI Agent'}
422
- </span>
423
- }
424
- description={
425
- <>
426
- <Text type="secondary">Created: {new Date(session.createdAt).toLocaleDateString()}</Text>
427
- {session.isBlurred && (
428
- <div className="closed-badge" style={{ color: '#ff4d4f', fontSize: '12px', marginTop: 4 }}>
429
- This session is closed and cannot be reopened.
430
- </div>
431
- )}
432
- </>
433
- }
434
- />
435
- </List.Item>
436
- )}
437
- />
438
- ) : (
439
- <div className="empty-state" style={{
440
- padding: '2rem 1rem',
441
- textAlign: 'center',
442
- color: '#666',
443
- background: 'rgba(255, 255, 255, 0.3)',
444
- backdropFilter: 'blur(10px)',
445
- WebkitBackdropFilter: 'blur(10px)',
446
- borderRadius: '12px',
447
- margin: '1rem',
448
- }}>
449
- No conversations yet.
450
- </div>
451
- )}
452
- </div>
453
-
454
- <div
455
- className="action-buttons-container"
456
- style={{
457
- padding: '16px',
458
- borderTop: '1px solid rgba(255, 255, 255, 0.18)',
459
- display: 'flex',
460
- gap: 12,
461
- background: 'rgba(255, 255, 255, 0.5)',
462
- backdropFilter: 'blur(20px) saturate(180%)',
463
- WebkitBackdropFilter: 'blur(20px) saturate(180%)',
464
- }}
465
- >
466
- <button
467
- onClick={onNewSession}
468
- className="action-button new-chat-button"
469
- style={{
470
- flex: 1,
471
- height: '56px',
472
- border: 'none',
473
- borderRadius: '16px',
474
- background: 'linear-gradient(135deg, #0A0A0A, #0A0A0Add)',
475
- color: 'white',
476
- fontSize: '20px',
477
- cursor: 'pointer',
478
- display: 'flex',
479
- alignItems: 'center',
480
- justifyContent: 'center',
481
- gap: '8px',
482
- }}
483
- >
484
- <MessageOutlined className="button-icon" style={{ fontSize: '22px' }} />
485
- <span style={{ fontSize: '15px', fontWeight: 600 }}>New Chat</span>
486
- </button>
487
-
488
- {Phone && (
489
- <button
490
- onClick={() => {
491
- const waLink = `https://wa.me/${Phone}`;
492
- window.open(waLink, '_blank');
493
- }}
494
- className="action-button whatsapp-button"
495
- style={{
496
- width: '56px',
497
- height: '56px',
498
- border: 'none',
499
- borderRadius: '16px',
500
- background: 'linear-gradient(135deg, #25D366, #20BA5A)',
501
- color: 'white',
502
- fontSize: '24px',
503
- cursor: 'pointer',
504
- display: 'flex',
505
- alignItems: 'center',
506
- justifyContent: 'center',
507
- flexShrink: 0,
508
- }}
509
- >
510
- <WhatsAppOutlined className="button-icon" />
511
- </button>
512
- )}
513
- </div>
514
- </div>
515
- </>
516
- );
517
- };
518
-
519
- export default ChatSessions;