wineater-bot 3.0.7 → 3.0.8
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/wineater-chatbot.mjs +2 -2
- package/dist/wineater-chatbot.umd.js +1 -1
- package/index.html +1 -1
- package/package.json +1 -1
- package/src/js/api.js +2 -2
- package/src/js/widget.js +1 -1
|
@@ -7260,7 +7260,7 @@ const Fa = ["climats", "telckel", "biobio", "weinpoint", "vinigrandi", "ampely",
|
|
|
7260
7260
|
class Ft {
|
|
7261
7261
|
constructor(e) {
|
|
7262
7262
|
var s;
|
|
7263
|
-
this.baseURL = "
|
|
7263
|
+
this.baseURL = "http://localhost:3000/", this.store = Fa.find((n) => window.location.href.includes(n)), this.token = ((s = window == null ? void 0 : window.wineaterData) == null ? void 0 : s.CLIENT_TOKEN) || Aa;
|
|
7264
7264
|
}
|
|
7265
7265
|
async getStoreConfig(e) {
|
|
7266
7266
|
console.log(e);
|
|
@@ -7590,7 +7590,7 @@ const H = new Da(), ds = {
|
|
|
7590
7590
|
class La {
|
|
7591
7591
|
constructor() {
|
|
7592
7592
|
var e;
|
|
7593
|
-
this.widgetType = ((e = window == null ? void 0 : window.wineaterData) == null ? void 0 : e.WIDGET_TYPE) || "
|
|
7593
|
+
this.widgetType = ((e = window == null ? void 0 : window.wineaterData) == null ? void 0 : e.WIDGET_TYPE) || "store", this.api = new Ft(), this.selectedFilters = {
|
|
7594
7594
|
price: null,
|
|
7595
7595
|
color: null,
|
|
7596
7596
|
intensity: null
|
|
@@ -1065,7 +1065,7 @@ If you're using serverside rendering in your app, make sure that tracker is load
|
|
|
1065
1065
|
.hidden {
|
|
1066
1066
|
display: none;
|
|
1067
1067
|
}
|
|
1068
|
-
`,pi=document.createElement("style");pi.textContent=Ra,document.head.appendChild(pi);const Fa=["climats","telckel","biobio","weinpoint","vinigrandi","ampely","test"],Aa="HeUw6IXuhvz6tRuXdPEGEbj3SGQ3Q2YtEc1Z8jd41Kg9LtyPb4Epu0to31SYIadG";class Rt{constructor(e){var s;this.baseURL="
|
|
1068
|
+
`,pi=document.createElement("style");pi.textContent=Ra,document.head.appendChild(pi);const Fa=["climats","telckel","biobio","weinpoint","vinigrandi","ampely","test"],Aa="HeUw6IXuhvz6tRuXdPEGEbj3SGQ3Q2YtEc1Z8jd41Kg9LtyPb4Epu0to31SYIadG";class Rt{constructor(e){var s;this.baseURL="http://localhost:3000/",this.store=Fa.find(n=>window.location.href.includes(n)),this.token=((s=window==null?void 0:window.wineaterData)==null?void 0:s.CLIENT_TOKEN)||Aa}async getStoreConfig(e){console.log(e);try{const s=await fetch(`${this.baseURL}stores/store`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`},body:JSON.stringify({store:e})});if(console.log(s),!s.ok)throw new Error(`HTTP error! Status: ${s.status}`);return await s.json()}catch(s){throw console.error("Error fetching store configuration:",s),s}}async getWineRecommendations(e){console.log(window.location.href);try{const s=await fetch(`${this.baseURL}dish/recommendations`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`},body:JSON.stringify({text:e,store:this.store?this.store.toString().charAt(0).toUpperCase()+this.store.slice(1):void 0})}),n=await s.json();if(!s.ok)throw new Error(`API call failed with status ${s.status}: ${n.message||"No additional error information"}`);return n}catch(s){throw console.error("Fetching wine recommendations failed:",s.message),new Error(`Error in getWineRecommendations: ${s.message}`)}}async getWineRecommendationsSearch(e){console.log(window.location.href);try{const s=await fetch(`${this.baseURL}dish/recommendations/search`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`},body:JSON.stringify({text:e,store:this.store?this.store.toString().charAt(0).toUpperCase()+this.store.slice(1):void 0})}),n=await s.json();if(!s.ok)throw new Error(`API call failed with status ${s.status}: ${n.message||"No additional error information"}`);return n}catch(s){throw console.error("Fetching wine recommendations failed:",s.message),new Error(`Error in getWineRecommendations: ${s.message}`)}}async getPossibleDishesWithMeta(e,s){try{const n=await fetch(`${this.baseURL}dish/possible_dishes`,{method:"POST",headers:{Authorization:`Bearer ${this.token}`,"Content-Type":"application/json"},body:JSON.stringify({title:e,description:s})}),i=await n.json();if(console.log(i),!n.ok)throw new Error(`API call failed with status ${n.status}: ${i.message||"No additional error information"}`);return i}catch(n){throw console.error("Error fetching possible dishes:",n),n}}async getInstantRecommendations(){console.log("Fetching instant recommendations...");try{const e=await fetch(`${this.baseURL}dish/recommendations/instant`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`},body:JSON.stringify({store:this.store})}),s=await e.json();if(!e.ok)throw new Error(`API call failed with status ${e.status}: ${s.message||"No additional error information"}`);return console.log("Instant recommendations:",s),s}catch(e){throw console.error("Fetching instant recommendations failed:",e.message),new Error(`Error in getInstantRecommendations: ${e.message}`)}}}class Da{constructor(){this.api=new Rt,this.language="en",this.translations={fr:{welcomeMessage:"Quel plat allez-vous déguster ? Décrivez-le-moi et je vous proposerai le vin qui l'accompagnera parfaitement.",noResultsFound:"Aucun résultat trouvé.",somethingWentWrong:"Désolé, quelque chose a mal tourné.",chatButton1:"Trouvez l'accord parfait",chatButton2:"Associez le vin",chatButton3:"Obtenez des conseils",chatTitle:"Accord Mets & Vins 🍷",chatSubtitle:"Décrivez votre plat et obtenez une recommandation en 30 secondes",inputPlaceholder:"ex., Salade de thon",sendButton:"Accorder",poweredBy:"Propulsé par",price:"Prix",region:"Région",type:"Type",reason:"Suggestion",moreInfo:"Plus d'infos",winePairingIntro:"Pour ce vin, voici quelques suggestions de plats :",askForDinner:"Que voulez-vous manger ce soir?",clearChatButton:"Effacer le chat",widgetTitle:"Découvrez votre vin",widgetSubtitle:"Recherchez par vos préférences",searchPlaceholder:"Entrez un mot-clé ou une description",searchButton:"Rechercher",priceRange:"Gamme de prix",wineColor:"Couleur du vin",intensity:"Intensité",red:"Rouge",white:"Blanc",rose:"Rosé",light:"Léger",medium:"Moyen",full:"Puissant",barTitle:"Sélection du bar",barSubtitle:"Choisissez vos plats ci-dessous et cliquez sur «Envoyer»",barSendButton:"Envoyer",barResetButton:"Réinitialiser",barName:"Nom du bar",barNotesPlaceholder:"Entrez vos souhaits ici..."},es:{welcomeMessage:"¿Qué vas a comer? Cuéntame tu plato y te recomendaré el maridaje perfecto.",noResultsFound:"No se encontraron resultados.",somethingWentWrong:"Lo sentimos, algo salió mal.",chatButton1:"Encuentra tu maridaje",chatButton2:"Combina vino ya",chatButton3:"Recibe asesoría ahora",chatTitle:"Maridaje de Vinos 🍷",chatSubtitle:"Describe tu comida y obtén una recomendación en 30 segundos",inputPlaceholder:"ej., Ensalada de atún",sendButton:"Combinar",poweredBy:"Desarrollado por",price:"Precio",region:"Región",type:"Tipo",reason:"Sugerencia",moreInfo:"Más info",winePairingIntro:"Para este vino, aquí tienes algunas sugerencias de platos:",askForDinner:"¿Qué te gustaría cenar?",clearChatButton:"Limpiar el chat",widgetTitle:"Encuentra tu vino",widgetSubtitle:"Busca según tus preferencias",searchPlaceholder:"Escribe una palabra clave o descripción",searchButton:"Buscar",priceRange:"Rango de precios",wineColor:"Color del vino",intensity:"Intensidad",red:"Tinto",white:"Blanco",rose:"Rosado",light:"Ligero",medium:"Medio",full:"Intenso",barTitle:"Platos de Bar",barSubtitle:"Selecciona de la lista y presiona «Enviar»",barSendButton:"Enviar",barResetButton:"Reiniciar",barName:"Nombre del bar",barNotesPlaceholder:"Agrega tus comentarios aquí..."},en:{welcomeMessage:"What are you planning to eat? Share your dish and I'll recommend the perfect wine pairing for your meal.",noResultsFound:"No results found.",somethingWentWrong:"Sorry, something went wrong.",chatButton1:"Find Your Pairing",chatButton2:"Pair Wine Now",chatButton3:"Get Wine Advice",chatTitle:"Wine Pairing Assistant 🍷",chatSubtitle:"Describe your meal and get a recommendation in 30 seconds",inputPlaceholder:"e.g., Tuna salad",sendButton:"Match",poweredBy:"Powered by",price:"Price",region:"Region",type:"Type",reason:"Suggestion",moreInfo:"More info",winePairingIntro:"For this wine, here are some suggested dishes:",askForDinner:"What would you like to have for dinner?",clearChatButton:"Clear Chat",widgetTitle:"Discover Your Wine",widgetSubtitle:"Search by your preferences",searchPlaceholder:"Enter a keyword or description",searchButton:"Search",priceRange:"Price Range",wineColor:"Wine Color",intensity:"Intensity",red:"Red",white:"White",rose:"Rosé",light:"Light",medium:"Medium",full:"Full",barTitle:"Bar Dishes",barSubtitle:"Select dishes below and click ‘Send’",barSendButton:"Send",barResetButton:"Reset",barName:"Bar Name",barNotesPlaceholder:"Add your wishes here..."},de:{welcomeMessage:"Was möchten Sie essen? Beschreiben Sie Ihr Gericht und ich empfehle Ihnen den perfekten Wein dazu.",noResultsFound:"Keine Ergebnisse gefunden.",somethingWentWrong:"Entschuldigung, etwas ist schief gelaufen.",chatButton1:"Finde Dein Pairing",chatButton2:"Wein jetzt wählen",chatButton3:"Erhalte Weinberatung",chatTitle:"Wein & Speisen 🍷",chatSubtitle:"Beschreiben Sie Ihr Gericht und erhalten Sie in 30 Sekunden eine Empfehlung",inputPlaceholder:"z.B., Thunfischsalat",sendButton:"Kombinieren",poweredBy:"Unterstützt von",price:"Preis",region:"Region",type:"Typ",reason:"Anregung",moreInfo:"Mehr Info",winePairingIntro:"Für diesen Wein gibt es folgende Essensvorschläge:",askForDinner:"Was möchten Sie zum Abendessen essen?",clearChatButton:"Chat löschen",widgetTitle:"Finden Sie Ihren Wein",widgetSubtitle:"Suchen Sie nach Ihren Vorlieben",searchPlaceholder:"Geben Sie ein Stichwort oder eine Beschreibung ein",searchButton:"Suche",priceRange:"Preisspanne",wineColor:"Weinfarbe",intensity:"Intensität",red:"Rot",white:"Weiß",rose:"Rosé",light:"Leicht",medium:"Mittel",full:"Voll",barTitle:"Bar-Auswahl",barSubtitle:"Wählen Sie Ihre Gerichte und klicken Sie auf „Senden“",barSendButton:"Senden",barResetButton:"Zurücksetzen",barName:"Name der Bar"}}}async fetchConfig(e){try{const s=await this.api.getStoreConfig(e);this.language=s.lang}catch{this.language="en"}}translate(e){return this.translations[this.language][e]||e}}const H=new Da,xs={barName:"LENEZ",dishGroups:[{groupTitle:"Entradas",dishes:["Pimientos rojo asado y aceite de oliva con ajo confitado","Ensalada de arúgula y parmesano","Tomate hierloom aliñado","Aceitunas LENEZ","PapaBnaz","Croquetas | hongos de temporada | jamón serrano","Carpaccio Cesar","Torreznos","Calamares fritos"]},{groupTitle:"Bocadillos",dishes:["Brioche de pollo frito, col y salsa macha","Baguette de calamares rebozados en salsa brava","Hogaza de cola de res en recado negro y cebollas encurtidas"]},{groupTitle:"Embutidos",dishes:["Jamón Ibérico de bellota","Lomo ibérico","Chorizo ibérico","Plato mixto"]},{groupTitle:"Quesos",dishes:["Selección de quesos"]},{groupTitle:"Postres",dishes:["Ate con queso manchego semi curado","Gelato de nata con balsámico","Gelato de ron con pasas y “El candado”, Valdespino PX","Gelato Dua Lipa","Créme Brûlée al Orange"]}]};class La{constructor(){var e;this.widgetType=((e=window==null?void 0:window.wineaterData)==null?void 0:e.WIDGET_TYPE)||"store",this.api=new Rt,this.selectedFilters={price:null,color:null,intensity:null},this.widgetType==="bar"?(this.barName=xs.barName,this.barDishes=xs.dishes):(this.barName="",this.barDishes=[]),this.initializeWidget(),this.widgetType==="store"&&this.loadInstantRecommendations()}initializeWidget(){const e=document.getElementById("wineater-widget-conteiner");if(this.widgetType==="store"){const s=`
|
|
1069
1069
|
<div id="wine-widget-container">
|
|
1070
1070
|
<div id="wine-widget-left">
|
|
1071
1071
|
<div id="wine-widget-header">
|
package/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Chatbot</title>
|
|
7
7
|
<!-- <script type="module" src="./dist/wineater-chatbot.umd.js"></script> -->
|
|
8
|
-
<script>window.wineaterData = {CLIENT_TOKEN: '
|
|
8
|
+
<script>window.wineaterData = {CLIENT_TOKEN: 'Y3I8Pi1FruGjVmIBqpV24PtOLYjzdROuxWX9tCXh82zjz7uUPxV3ETvHhoeiLS17', position: 'right-center', TYPE: 'widget', WIDGET_TYPE: 'bar'};</script>
|
|
9
9
|
<script type="module" src="./src/index.js"></script>
|
|
10
10
|
</head>
|
|
11
11
|
<body style="margin: 0;">
|
package/package.json
CHANGED
package/src/js/api.js
CHANGED
|
@@ -6,8 +6,8 @@ const DEMO_TOKEN='HeUw6IXuhvz6tRuXdPEGEbj3SGQ3Q2YtEc1Z8jd41Kg9LtyPb4Epu0to31SYIa
|
|
|
6
6
|
export class Api {
|
|
7
7
|
constructor(apiEndpoint) {
|
|
8
8
|
// Allow users of the library to specify their own endpoint if needed
|
|
9
|
-
|
|
10
|
-
this.baseURL = 'https://wineater-backend.vercel.app/';
|
|
9
|
+
this.baseURL = 'http://localhost:3000/';
|
|
10
|
+
// this.baseURL = 'https://wineater-backend.vercel.app/';
|
|
11
11
|
this.store = stores.find(value => window.location.href.includes(value));
|
|
12
12
|
this.token = window?.wineaterData?.CLIENT_TOKEN || DEMO_TOKEN;
|
|
13
13
|
}
|
package/src/js/widget.js
CHANGED
|
@@ -7,7 +7,7 @@ import { barConfig } from './barConfig.js';
|
|
|
7
7
|
export class WineWidget {
|
|
8
8
|
constructor() {
|
|
9
9
|
// Определяем тип виджета: 'store' (старый) или 'bar' (новый)
|
|
10
|
-
this.widgetType = window?.wineaterData?.WIDGET_TYPE || '
|
|
10
|
+
this.widgetType = window?.wineaterData?.WIDGET_TYPE || 'store';
|
|
11
11
|
this.api = new Api();
|
|
12
12
|
|
|
13
13
|
// Фильтры для store
|