wineater-bot 3.0.6 → 3.0.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wineater-bot",
3
- "version": "3.0.6",
3
+ "version": "3.0.7",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "src/index.js",
package/src/js/i18n.js CHANGED
@@ -45,6 +45,7 @@ class Translator {
45
45
  barSendButton: "Envoyer",
46
46
  barResetButton: "Réinitialiser",
47
47
  barName: "Nom du bar",
48
+ barNotesPlaceholder: "Entrez vos souhaits ici...",
48
49
  },
49
50
  es: {
50
51
  welcomeMessage: "¿Qué vas a comer? Cuéntame tu plato y te recomendaré el maridaje perfecto.",
@@ -86,6 +87,7 @@ class Translator {
86
87
  barSendButton: "Enviar",
87
88
  barResetButton: "Reiniciar",
88
89
  barName: "Nombre del bar",
90
+ barNotesPlaceholder: "Agrega tus comentarios aquí...",
89
91
  },
90
92
  en: {
91
93
  welcomeMessage: "What are you planning to eat? Share your dish and I'll recommend the perfect wine pairing for your meal.",
@@ -127,6 +129,7 @@ class Translator {
127
129
  barSendButton: "Send",
128
130
  barResetButton: "Reset",
129
131
  barName: "Bar Name",
132
+ barNotesPlaceholder: "Add your wishes here...",
130
133
  },
131
134
  de: {
132
135
  welcomeMessage: "Was möchten Sie essen? Beschreiben Sie Ihr Gericht und ich empfehle Ihnen den perfekten Wein dazu.",
@@ -352,45 +352,54 @@ const widgetStyles = `
352
352
  }
353
353
 
354
354
  /* Кнопка "Отправить" для бар-версии */
355
- #bar-send-button {
356
- padding: 12px 20px;
357
- background: linear-gradient(90deg, #7B2BEB, #0044FF);
358
- color: white;
359
- border: none;
360
- border-radius: 8px;
361
- cursor: pointer;
362
- font-size: 16px;
363
- transition: all 0.2s ease;
364
- text-align:center;
365
- margin-top: 16px;
355
+
356
+ #bar-controls {
357
+ display: flex;
358
+ align-items: stretch; /* или center, если нужно выравнивать */
359
+ gap: 8px;
360
+ margin-top: 16px;
366
361
  }
367
362
 
368
- #bar-send-button:hover {
369
- transform: scale(1.05);
370
- box-shadow: 0 4px 8px rgba(123, 43, 235, 0.15);
363
+ /* Задаем одной высотой и одинаковыми отступами */
364
+ #bar-controls input,
365
+ #bar-controls button {
366
+ height: 44px; /* или 48px, как вам нравится */
367
+ line-height: 44px; /* чтобы текст по вертикали выровнялся */
368
+ box-sizing: border-box; /* подстраховка, чтобы высота учитывала бордер */
369
+ }
370
+
371
+ /* Чтобы кнопка и инпут смотрелись схоже по высоте */
372
+ #bar-notes-input {
373
+ flex: 1;
374
+ padding: 0 12px; /* уберите или уменьшите вертикальные padding’и */
375
+ border: 1px solid #ccc;
376
+ border-radius: 6px;
377
+ font-size: 14px;
378
+ outline: none;
371
379
  }
372
380
 
373
- /* Кнопка "Сбросить" (bar-reset-button), стили как у bar-send-button */
381
+ /* Кнопки – чуть меняем паддинги, чтобы не «лезли» за высоту */
382
+ #bar-send-button,
374
383
  #bar-reset-button {
375
- padding: 12px 20px;
384
+ padding: 0 20px; /* а по вертикали пусть высота сама регулируется через height */
385
+ border-radius: 6px;
376
386
  background: linear-gradient(90deg, #7B2BEB, #0044FF);
377
- color: white;
378
- border: none;
379
- border-radius: 8px;
380
- cursor: pointer;
381
- font-size: 16px;
382
- transition: all 0.2s ease;
383
- margin-top: 16px; /* или подстройте под свой макет */
384
- margin-left: 12px; /* чтобы отступить от кнопки "Отправить" */
387
+ font-size: 14px;
388
+ cursor: pointer;
389
+ white-space: nowrap;
390
+ color: white;
391
+ border: none;
385
392
  }
386
393
 
387
- #bar-reset-button
388
-
394
+ /* При желании hover-эффект сохранить: */
395
+ #bar-send-button:hover,
389
396
  #bar-reset-button:hover {
390
- transform: scale(1.05);
391
- box-shadow: 0 4px 8px rgba(123, 43, 235, 0.15);
397
+ transform: scale(1.05);
398
+ box-shadow: 0 4px 8px rgba(123, 43, 235, 0.15);
392
399
  }
393
400
 
401
+
402
+
394
403
  .hidden {
395
404
  display: none;
396
405
  }
package/src/js/widget.js CHANGED
@@ -118,21 +118,27 @@ export class WineWidget {
118
118
 
119
119
  <div id="wine-placeholder"></div>
120
120
 
121
+ <div id="loading-indicator" class="hidden">
122
+ <div id="typing-indicator" class="typing-indicator">
123
+ <span></span><span></span><span></span>
124
+ </div>
125
+ </div>
126
+
121
127
  <!-- Кнопки для отправки и сброса -->
122
- <div id="bar-buttons">
123
- <button id="bar-send-button">
124
- ${translator.translate('barSendButton')}
125
- </button>
126
- <button id="bar-reset-button" class="hidden">
127
- ${translator.translate('barResetButton')}
128
- </button>
129
- </div>
128
+ <div id="bar-controls">
129
+ <input
130
+ type="text"
131
+ id="bar-notes-input"
132
+ placeholder="${translator.translate('barNotesPlaceholder')}"
133
+ />
134
+ <button id="bar-send-button">
135
+ ${translator.translate('barSendButton')}
136
+ </button>
137
+ <button id="bar-reset-button" class="hidden">
138
+ ${translator.translate('barResetButton')}
139
+ </button>
140
+ </div>
130
141
 
131
- <div id="loading-indicator" class="hidden">
132
- <div id="typing-indicator" class="typing-indicator">
133
- <span></span><span></span><span></span>
134
- </div>
135
- </div>
136
142
  </div>
137
143
  </div>
138
144
  `;
@@ -309,75 +315,97 @@ export class WineWidget {
309
315
  }
310
316
  }
311
317
  addEventListenersBarVersion() {
312
- // Клик по плиткам
318
+ // Теперь плитки блюд появятся только после renderDishGroups()
313
319
  const tileElements = document.querySelectorAll('.dish-tile');
314
- tileElements.forEach((tile) => {
315
- tile.addEventListener('click', () => {
316
- tile.classList.toggle('selected');
317
- });
320
+ tileElements.forEach(tile => {
321
+ tile.addEventListener('click', () => {
322
+ tile.classList.toggle('selected');
323
+ });
318
324
  });
319
-
320
- // Собираем все .dish-grid
321
- const dishGrids = document.querySelectorAll('.dish-grid');
322
-
323
- // Кнопки
324
- const sendButton = document.getElementById('bar-send-button');
325
- const resetButton = document.getElementById('bar-reset-button');
325
+
326
+ // Собираем все группы (или все .dish-grid)
327
+ const dishGroups = document.querySelectorAll('.dish-group');
328
+
329
+ // Находим элементы управления
330
+ const sendButton = document.getElementById('bar-send-button');
331
+ const resetButton = document.getElementById('bar-reset-button');
332
+ const notesInput = document.getElementById('bar-notes-input');
326
333
  const winePlaceholder = document.getElementById('wine-placeholder');
327
-
328
- if (!sendButton || !resetButton || !winePlaceholder) return;
329
-
330
- // Нажатие «Отправить»
334
+
335
+ if (!sendButton || !resetButton || !notesInput || !winePlaceholder) return;
336
+
337
+ // Нажатие "Отправить"
331
338
  sendButton.addEventListener('click', async () => {
332
- this.showLoadingIndicator();
333
-
334
- // Скрываем все группы/гриды блюд
335
- dishGrids.forEach((dg) => dg.classList.add('hidden'));
336
- // Прячем кнопку «Отправить»
337
- sendButton.classList.add('hidden');
338
-
339
- // Собираем выбранные блюда
340
- const selectedDishes = [];
341
- document.querySelectorAll('.dish-tile.selected').forEach(selectedTile => {
342
- selectedDishes.push(selectedTile.dataset.dish);
343
- });
344
-
345
- const query = selectedDishes.join(', ');
346
- console.log('Selected bar dishes =>', query);
347
-
348
- try {
349
- const results = await this.api.getWineRecommendationsSearch(query);
350
- if (results && results.length > 0) {
351
- this.displayResults(results, true);
352
- } else {
353
- this.displayNoResultsMessage();
354
- }
355
- // Показываем кнопку «Сбросить»
356
- resetButton.classList.remove('hidden');
357
- } catch (error) {
358
- console.error('Error while fetching bar recommendations:', error);
359
- this.displayErrorMessage();
360
- } finally {
361
- this.hideLoadingIndicator();
339
+ dishGroups.forEach(g => g.classList.add('hidden'));
340
+ this.showLoadingIndicator();
341
+
342
+ // 1) Собираем выбранные блюда
343
+ const selectedDishes = [];
344
+ document.querySelectorAll('.dish-tile.selected').forEach(tile => {
345
+ selectedDishes.push(tile.dataset.dish);
346
+ });
347
+
348
+ // 2) Берём пожелания (notes)
349
+ const notes = notesInput.value.trim(); // не стираем и не скрываем поле
350
+
351
+ // 3) Формируем запрос
352
+ const queryParts = [];
353
+ if (selectedDishes.length > 0) {
354
+ queryParts.push(`Dishes: ${selectedDishes.join(', ')}`);
355
+ }
356
+ if (notes) {
357
+ queryParts.push(`Notes: ${notes}`);
358
+ }
359
+ const finalQuery = queryParts.join('; ');
360
+
361
+ console.log('Final query =>', finalQuery);
362
+
363
+ try {
364
+ // 4) Делаете запрос к API
365
+ const results = await this.api.getWineRecommendationsSearch(finalQuery);
366
+
367
+ // 5) Скрываем группы блюд (если хотите, чтобы больше не мешались)
368
+
369
+ // 6) Отображаем результаты
370
+ if (results && results.length > 0) {
371
+ this.displayResults(results, true);
372
+ } else {
373
+ this.displayNoResultsMessage();
362
374
  }
375
+
376
+ // 7) Показываем кнопку «Сбросить»
377
+ resetButton.classList.remove('hidden');
378
+
379
+ // 8) Кнопку «Отправить» НЕ скрываем — оставляем!
380
+ // ...никакого sendButton.classList.add('hidden')
381
+ } catch (error) {
382
+ console.error('Error while fetching bar recommendations:', error);
383
+ this.displayErrorMessage();
384
+ } finally {
385
+ this.hideLoadingIndicator();
386
+ }
363
387
  });
364
-
365
- // Нажатие «Сбросить»
388
+
389
+ // Нажатие "Сбросить"
366
390
  resetButton.addEventListener('click', () => {
367
- // Показываем снова все гриды
368
- dishGrids.forEach((dg) => dg.classList.remove('hidden'));
369
-
370
- // Снимаем выделение со всех плиток
371
- tileElements.forEach(tile => tile.classList.remove('selected'));
372
-
373
- // Очищаем контейнер с результатами
374
- winePlaceholder.innerHTML = '';
375
-
376
- // Прячем кнопку «Сбросить»
377
- resetButton.classList.add('hidden');
378
-
379
- // Снова показываем кнопку «Отправить»
380
- sendButton.classList.remove('hidden');
391
+ // 1) Показываем все группы (блюда)
392
+ dishGroups.forEach(g => g.classList.remove('hidden'));
393
+
394
+ // 2) Снимаем выделение с плиток
395
+ tileElements.forEach(tile => tile.classList.remove('selected'));
396
+
397
+ // 3) Очищаем результаты
398
+ winePlaceholder.innerHTML = '';
399
+
400
+ // 4) Прячем кнопку «Сбросить»
401
+ resetButton.classList.add('hidden');
402
+
403
+ notesInput.value = '';
404
+
405
+ // 5) Инпут с пожеланиями НЕ трогаем — пусть остается, пользователь может менять
406
+ // notesInput.value = ''; // Если захотите — можете раскомментить, чтобы тоже сбрасывать
407
+
408
+ // 6) «Отправить» и дальше на месте, не меняется
381
409
  });
382
- }
410
+ }
383
411
  }