wineater-bot 3.2.1 → 3.4.0

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/index.html CHANGED
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Chatbot</title>
7
- <script>window.wineaterData = {CLIENT_TOKEN: 'dRBwg6wB6LeEKFUiLHdlXa84TgSVDuR8HhE0hhq1l4vVeq3cE12DJkPDwXvuhT01', TYPE: 'widget', WIDGET_TYPE: 'store', WIDGET_WRAPPER: 'wineater-widget-conteiner'};</script>
7
+ <script>window.wineaterData = {CLIENT_TOKEN: 'Joc4OSMwtwiczAzBlcjso3M1mSysGGCMi2h2yYkuWE4fkdupkI8BowDfFvvvpTFf', TYPE: 'widget', WIDGET_TYPE: 'bar', WIDGET_WRAPPER: 'wineater-widget-conteiner'};</script>
8
8
  <!-- <script type="module" src="./dist/wineater-chatbot.umd.js"></script> -->
9
9
  <script type="module" src="./src/index.js"></script>
10
10
  </head>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wineater-bot",
3
- "version": "3.2.1",
3
+ "version": "3.4.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "src/index.js",
package/src/index.js CHANGED
@@ -1,39 +1,14 @@
1
- import './js/styles.js';
2
1
  import { setCookie, setUniqueUserCookie, getCookie } from './js/analytics.js';
3
2
  import flagsmith from 'flagsmith';
4
3
  import Tracker from '@openreplay/tracker';
5
4
  import { WineWidget } from './js/widget.js';
6
- import { Chatbot } from './js/chatbot.js';
7
5
  import translator from './js/i18n.js';
8
- import { shouldOpenChatAutomatically } from './js/auto-open.js';
9
- import { toggleChatWindow, closeChatWindow, openChatWindow } from './js/ui.js';
10
6
 
11
7
  const DEMO_TOKEN = 'HeUw6IXuhvz6tRuXdPEGEbj3SGQ3Q2YtEc1Z8jd41Kg9LtyPb4Epu0to31SYIadG';
12
8
 
13
9
  class App {
14
10
  constructor() {
15
- this.stores = ['climats', 'telckel', 'biobio', 'weinpoint', 'vinigrandi', 'ampely', 'test'];
16
11
  this.tracker = new Tracker({ projectKey: "PA8j9fAi49i6g2QnvpNs", '__DISABLE_SECURE_MODE': true });
17
- this.position = window?.wineaterData?.POSITION || 'right-center';
18
- this.type = window?.wineaterData?.TYPE || 'chatbot';
19
- this.store = this.detectStore();
20
- }
21
-
22
- detectStore() {
23
- return this.stores.find(store => window.location.href.includes(store)) || null;
24
- }
25
-
26
- async initFlagsmith() {
27
- try {
28
- await flagsmith.init({
29
- environmentID: '5RfiDoiqb4dHrNdQvzbkfM',
30
- cacheFlags: false,
31
- enableAnalytics: true,
32
- identity: getCookie('uniqueUserID'),
33
- });
34
- } catch (error) {
35
- console.error('Flagsmith initialization failed:', error);
36
- }
37
12
  }
38
13
 
39
14
  async initTranslator() {
@@ -46,84 +21,15 @@ class App {
46
21
  setUniqueUserCookie();
47
22
  }
48
23
 
49
- async initializeChatbotOrWidget() {
50
- if (this.type === 'widget') {
51
- new WineWidget();
52
- } else {
53
- this.createChatbotUI();
54
- this.setupChatListeners();
55
- this.setupChatButtonListener();
56
- applyPositionToChat(this.position);
57
- const chatbot = new Chatbot();
58
- chatbot.initialize();
59
- }
60
- }
61
-
62
- createChatbotUI() {
63
- const chatbotHTML = ``;
64
- document.body.insertAdjacentHTML('beforeend', chatbotHTML);
65
- }
66
-
67
- setupChatListeners() {
68
- const closeButton = document.getElementById('close-btn');
69
- closeButton.addEventListener('click', toggleChatWindow);
70
-
71
- window.addEventListener('click', event => {
72
- const chatWindow = document.getElementById('chat-window');
73
- const chatIcon = document.getElementById('chat-icon');
74
- if (!chatWindow.contains(event.target) && !chatIcon.contains(event.target)) {
75
- chatWindow.classList.remove('visible');
76
- chatIcon.style.display = 'flex';
77
- }
78
- });
79
- }
80
-
81
- autoOpenChatIfNeeded() {
82
- const disableAutoOpen = getCookie('disableAutoOpen');
83
- if (!disableAutoOpen) {
84
- shouldOpenChatAutomatically();
85
- }
86
- }
87
-
88
- setupChatButtonListener() {
89
- const chatIcon = document.getElementById('chat-icon');
90
- const chatWindow = document.getElementById('chat-window');
91
-
92
- if (!chatIcon || !chatWindow) {
93
- console.error('Chat icon or chat window element not found!');
94
- return;
95
- }
96
-
97
- chatIcon.addEventListener('click', () => {
98
- const isVisible = chatWindow.classList.contains('visible');
99
- if (isVisible) {
100
- chatWindow.classList.remove('visible');
101
- chatIcon.style.display = 'flex';
102
- } else {
103
- chatWindow.classList.add('visible');
104
- chatIcon.style.display = 'none';
105
- }
106
- });
107
- }
108
24
 
109
25
  async initialize() {
110
26
  this.tracker.start();
111
- await this.initFlagsmith();
112
27
  await this.initTranslator();
113
28
  this.initCookies();
114
- await this.initializeChatbotOrWidget();
115
- this.autoOpenChatIfNeeded();
29
+ new WineWidget();
116
30
  }
117
31
  }
118
32
 
119
- function applyPositionToChat(position = 'right-center') {
120
- const chatIcon = document.getElementById('chat-icon');
121
- if (!chatIcon) return;
122
-
123
- // Применение классов для позиции
124
- chatIcon.className = `chat-icon-${position}`;
125
- }
126
-
127
33
  // Initialize the application on DOM ready
128
34
  document.addEventListener('DOMContentLoaded', () => {
129
35
  const app = new App();
package/src/js/i18n.js CHANGED
@@ -4,6 +4,18 @@ class Translator {
4
4
  constructor() {
5
5
  this.api = new Api();
6
6
  this.language = 'en'; // Default to English
7
+ this.currency = 'USD';
8
+ this.currencies = {
9
+ 'USD': {
10
+ label: '$'
11
+ },
12
+ 'EUR': {
13
+ label: '€'
14
+ },
15
+ 'MXN': {
16
+ label: '$'
17
+ }
18
+ }
7
19
  this.translations = {
8
20
  fr: {
9
21
  lang: 'fr',
@@ -400,9 +412,26 @@ class Translator {
400
412
  try {
401
413
  const config = await this.api.getStoreConfig(storeName);
402
414
  this.language = config.lang;
415
+ this.currency = config.currency;
403
416
  } catch (e) {
404
417
  this.language = 'en'; // Fallback to English
418
+ this.currency = 'USD';
419
+ }
420
+ }
421
+
422
+ getCurrency(key) {
423
+ const keys = key.split('.'); // Разбиваем ключ на части
424
+ let value = this.currencies[this.currency];
425
+
426
+ for (const k of keys) {
427
+ if (value && typeof value === 'object' && k in value) {
428
+ value = value[k]; // Переходим к следующему уровню
429
+ } else {
430
+ return this.currency; // Если ключ не найден, возвращаем сам ключ
431
+ }
405
432
  }
433
+
434
+ return value;
406
435
  }
407
436
 
408
437
  translate(key) {
@@ -144,7 +144,8 @@ body {
144
144
  }
145
145
 
146
146
  #wine-widget-container #wine-search-input {
147
- flex: 1 1 auto;
147
+ flex: 1 1 0%;
148
+ min-width: 0;
148
149
  padding: 12px; /* место под иконку и кнопку */
149
150
  font-size: 16px;
150
151
  border: none;
@@ -313,7 +314,7 @@ flex: 0 0 auto;
313
314
 
314
315
  /* Заголовок вина */
315
316
  #wine-widget-container .wine-title {
316
- font-size: 18px; /* крупнее */
317
+ font-size: 15px; /* крупнее */
317
318
  font-weight: 500;
318
319
  margin: 0 0 8px;
319
320
  min-height: 3rem;
@@ -489,6 +490,58 @@ margin-top: auto; /* прижимает .bottom-row к низу
489
490
  animation: spin 1s linear infinite;
490
491
  }
491
492
 
493
+ .typing-indicator {
494
+ display: flex;
495
+ justify-content: center;
496
+ align-items: center;
497
+ height: 0;
498
+ visibility: hidden;
499
+ background-color: white;
500
+ }
501
+
502
+ #loading-indicator .typing-indicator {
503
+ visibility: visible;
504
+ }
505
+
506
+ .typing-indicator span {
507
+ display: block;
508
+ width: 8px;
509
+ height: 8px;
510
+ margin: 0 3px;
511
+ border-radius: 50%;
512
+ background: linear-gradient(90deg, var(--wineater-color), var(--wineater-corp-color));
513
+ opacity: 0.7;
514
+ animation: typing 1s infinite;
515
+ }
516
+
517
+ @keyframes typing {
518
+ 0%, 100% {
519
+ transform: translateY(0);
520
+ opacity: 0.7;
521
+ }
522
+ 50% {
523
+ transform: translateY(-8px);
524
+ opacity: 1;
525
+ }
526
+ }
527
+
528
+ /* Staggered animation for typing dots */
529
+ .typing-indicator span:nth-child(1) {
530
+ animation-delay: 0s;
531
+ }
532
+ .typing-indicator span:nth-child(2) {
533
+ animation-delay: 0.15s;
534
+ }
535
+ .typing-indicator span:nth-child(3) {
536
+ animation-delay: 0.3s;
537
+ }
538
+
539
+ /* Show the typing indicator */
540
+ .typing-indicator.visible {
541
+ visibility: visible;
542
+ height: 40px;
543
+ }
544
+
492
545
  /* ===================== 11) keyframes анимации ===================== */
493
546
  @keyframes spin {
494
547
  from { transform: rotate(0deg); }
@@ -628,6 +681,134 @@ margin-top: auto; /* прижимает .bottom-row к низу
628
681
  }
629
682
  }
630
683
 
684
+ .card-popup {
685
+ position: absolute;
686
+ top: 0;
687
+ left: 0;
688
+ z-index: 10;
689
+ width: 100%;
690
+ background-color: white;
691
+ padding: 16px;
692
+ border-radius: 16px;
693
+ box-shadow: 0 6px 30px rgba(0,0,0,0.2);
694
+ text-align: left;
695
+ font-size: 14px;
696
+ box-sizing: border-box;
697
+ display: flex;
698
+ flex-direction: column;
699
+ }
700
+
701
+ .card-popup p {
702
+ margin: 5px 0;
703
+ }
704
+
705
+ .card-popup.hidden {
706
+ display: none;
707
+ }
708
+
709
+ .card-popup-header {
710
+ display: flex;
711
+ justify-content: space-between;
712
+ align-items: flex-start;
713
+ gap: 12px;
714
+ }
715
+
716
+ .card-popup-header h2 {
717
+ font-size: 16px;
718
+ font-weight: 600;
719
+ margin: 0;
720
+ flex: 1;
721
+ line-height: 1.3;
722
+ }
723
+
724
+ .card-popup-close {
725
+ font-size: 20px;
726
+ font-weight: bold;
727
+ cursor: pointer;
728
+ color: #999;
729
+ border: none;
730
+ background: transparent;
731
+ line-height: 1;
732
+ }
733
+ .card-popup-close:hover {
734
+ color: #000;
735
+ }
736
+
737
+ .global-card-popup {
738
+ position: fixed;
739
+ top: 0;
740
+ left: 0;
741
+ right: 0;
742
+ bottom: 0;
743
+ z-index: 10000;
744
+ padding: 24px 16px;
745
+ background-color: #fff;
746
+ overflow-y: auto;
747
+ border-radius: 0;
748
+ font-size: 14px;
749
+ box-shadow: 0 6px 20px rgba(0,0,0,0.2);
750
+ display: flex;
751
+ flex-direction: column;
752
+ gap: 12px;
753
+ max-width: 100vw;
754
+ max-height: 100vh;
755
+ }
756
+
757
+ .global-card-popup .card-popup-header {
758
+ display: flex;
759
+ justify-content: space-between;
760
+ align-items: flex-start;
761
+ }
762
+
763
+ .global-card-popup .card-popup-close {
764
+ font-size: 24px;
765
+ font-weight: bold;
766
+ cursor: pointer;
767
+ background: transparent;
768
+ border: none;
769
+ }
770
+
771
+ .mobile-fullscreen-popup {
772
+ font-family: 'Bricolage Grotesque', sans-serif;
773
+ position: fixed;
774
+ width: calc(100% - 20px);
775
+ top: 50px;
776
+ left: 10px;
777
+ z-index: 10000;
778
+ background-color: #fff;
779
+ padding: 24px;
780
+ overflow-y: auto;
781
+ border-radius: 0;
782
+ border-radius: 16px;
783
+ font-size: 14px;
784
+ display: flex;
785
+ flex-direction: column;
786
+ gap: 12px;
787
+ }
788
+ .mobile-fullscreen-popup .card-popup-header {
789
+ display: flex;
790
+ justify-content: space-between;
791
+ align-items: flex-start;
792
+ }
793
+ .mobile-fullscreen-overlay {
794
+ position: absolute;
795
+ top: 0;
796
+ left: 0;
797
+ right: 0;
798
+ bottom: 0;
799
+ background: #fff;
800
+ opacity: 0.96;
801
+ z-index: 0;
802
+ }
803
+ .mobile-fullscreen-popup .card-popup-close {
804
+ font-size: 24px;
805
+ font-weight: bold;
806
+ cursor: pointer;
807
+ background: transparent;
808
+ border: none;
809
+ }
810
+
811
+
631
812
  /* Пример более узких экранов (i.e. <480px) можно добавить при необходимости */
632
813
  `;
633
814
  const fontLink = document.createElement('link');