wineater-bot 1.1.1 → 1.1.2

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.
@@ -316,7 +316,7 @@ function u() {
316
316
  document.body.insertAdjacentHTML("beforeend", `
317
317
  <div id="chatbot-container">
318
318
  <div id="chat-icon" onclick="toggleChatWindow()">
319
- <img src="/src/assets/images/chat-icon.svg" alt="Chat Icon">
319
+ <img src="https://landing-static.s3.eu-central-1.amazonaws.com/images/chat-icon.svg" alt="Chat Icon">
320
320
  </div>
321
321
 
322
322
  <div id="chat-window" class="hidden">
@@ -233,7 +233,7 @@
233
233
  }`,r=document.createElement("style");r.textContent=s,document.head.appendChild(r);function d(){document.getElementById("chat-window").classList.toggle("visible")}function c(){document.getElementById("chat-window").classList.remove("visible")}function l(){document.getElementById("chat-window").classList.add("visible")}document.addEventListener("DOMContentLoaded",()=>{setupCloseButton(),setupOutsideClick()});class h{constructor(n){this.apiEndpoint=n||"https://api.wineater.com/dish/recommendations"}async getWineRecommendations(n){try{const t=await fetch(this.apiEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:n})}),e=await t.json();if(!t.ok)throw new Error(`API call failed with status ${t.status}: ${e.message||"No additional error information"}`);return e}catch(t){throw console.error("Fetching wine recommendations failed:",t.message),new Error(`Error in getWineRecommendations: ${t.message}`)}}}class u{constructor(){this.api=new h}initialize(){document.getElementById("send-button").addEventListener("click",()=>this.handleUserInput()),document.getElementById("user-input").addEventListener("keypress",e=>{e.key==="Enter"&&this.handleUserInput()})}async handleUserInput(){const n=document.getElementById("user-input"),t=n.value.trim();if(t){this.displayMessage(t,"user"),n.value="",this.showTypingIndicator();try{const e=await this.api.getWineRecommendations(t);this.hideTypingIndicator(),e&&e.length?this.displayResults(e):this.displayMessage("No results found.","api")}catch(e){this.hideTypingIndicator(),console.error("Error fetching wine recommendations:",e),this.displayMessage("Sorry, something went wrong.","api")}}}showTypingIndicator(){document.getElementById("typing-indicator").classList.add("visible")}hideTypingIndicator(){document.getElementById("typing-indicator").classList.remove("visible")}displayMessage(n,t){const e=document.getElementById("message-container"),a=document.createElement("div");a.textContent=n,a.className="message "+t,e.appendChild(a),e.scrollTop=e.scrollHeight}displayResults(n){const t=document.getElementById("message-container");n.forEach(e=>{const a=document.createElement("div");a.className="wine-item";const p=document.createElement("img");p.src=e.Image,a.appendChild(p);const g=document.createElement("div");g.innerHTML=`<strong>${e.Title}</strong><br>Price: ${e.Price}<br>Region: ${e.Region}<br>Type: ${e.Type}<br><a href="${e.Url}" target="_blank">More Info</a>`,a.appendChild(g),t.appendChild(a)}),t.scrollTop=t.scrollHeight}}document.addEventListener("DOMContentLoaded",()=>{window.toggleChatWindow=d,window.closeChatWindow=c,window.openChatWindow=l});function m(){document.body.insertAdjacentHTML("beforeend",`
234
234
  <div id="chatbot-container">
235
235
  <div id="chat-icon" onclick="toggleChatWindow()">
236
- <img src="/src/assets/images/chat-icon.svg" alt="Chat Icon">
236
+ <img src="https://landing-static.s3.eu-central-1.amazonaws.com/images/chat-icon.svg" alt="Chat Icon">
237
237
  </div>
238
238
 
239
239
  <div id="chat-window" class="hidden">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wineater-bot",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "src/index.js",