wineater-bot 3.0.21 → 3.0.22
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.
|
@@ -7841,6 +7841,7 @@ class La {
|
|
|
7841
7841
|
displayResults(e, n = !1) {
|
|
7842
7842
|
const s = document.getElementById("wine-placeholder");
|
|
7843
7843
|
this.hideLoadingIndicator(), s.innerHTML = "", e.forEach((i, r) => {
|
|
7844
|
+
r === e.length - 1 && this.widgetType === "store" && (i.isSommSelection = !0), console.log(i);
|
|
7844
7845
|
const o = `
|
|
7845
7846
|
<div class="wine-recommendation-tile ${i.isSommSelection ? "somm-selection" : ""}">
|
|
7846
7847
|
${i.isSommSelection ? `<div class="somm-selection-badge">${q.translate("wineDetails.sommSelection")}</div>` : ""}
|
|
@@ -1208,7 +1208,7 @@ width: 100%;
|
|
|
1208
1208
|
|
|
1209
1209
|
</div>
|
|
1210
1210
|
</div>
|
|
1211
|
-
`;e.insertAdjacentHTML("beforeend",n),this.addEventListenersBarVersion()}this.initializeSearchAnimation()}addEventListenersStoreVersion(){document.getElementById("wine-search-button").addEventListener("click",()=>this.handleSearch()),this.setupFilterButtons("price-buttons","price"),this.setupFilterButtons("color-buttons","color"),this.setupFilterButtons("intensity-buttons","intensity"),document.getElementById("wine-search-input").addEventListener("keydown",e=>{e.key==="Enter"&&this.handleSearch()})}setupFilterButtons(e,n){const s=document.querySelectorAll(`#${e} button`);s.forEach(i=>{i.addEventListener("click",r=>{s.forEach(o=>o.classList.remove("selected")),r.target.classList.add("selected"),this.selectedFilters[n]=r.target.dataset.value,this.handleSearch()})})}async handleSearch(){const e="wine for dish:"+document.getElementById("wine-search-input").value.trim()+";",n=this.selectedFilters,s=[];n.price&&s.push(`price: ${n.price||"any"};`),n.color&&s.push(`color: ${n.color||"any"}; `),n.intensity&&s.push(`intensity: ${n.intensity||"any"}; `);const i=s.length>0?`${e} ${s.join(", ")}`:e;console.log("Searching for:",i),console.log("Applied filters:",n),this.animateCardDisappearance();try{const r=await this.api.getWineRecommendationsSearch(i);r&&r.length>0?(console.log("Recommendations:",r),this.displayResults(r,!0)):(console.log("No recommendations found."),this.displayNoResultsMessage())}catch(r){console.error("Error fetching wine recommendations:",r.message),this.displayErrorMessage()}}displayResults(e,n=!1){const s=document.getElementById("wine-placeholder");this.hideLoadingIndicator(),s.innerHTML="",e.forEach((i,r)=>{const o=`
|
|
1211
|
+
`;e.insertAdjacentHTML("beforeend",n),this.addEventListenersBarVersion()}this.initializeSearchAnimation()}addEventListenersStoreVersion(){document.getElementById("wine-search-button").addEventListener("click",()=>this.handleSearch()),this.setupFilterButtons("price-buttons","price"),this.setupFilterButtons("color-buttons","color"),this.setupFilterButtons("intensity-buttons","intensity"),document.getElementById("wine-search-input").addEventListener("keydown",e=>{e.key==="Enter"&&this.handleSearch()})}setupFilterButtons(e,n){const s=document.querySelectorAll(`#${e} button`);s.forEach(i=>{i.addEventListener("click",r=>{s.forEach(o=>o.classList.remove("selected")),r.target.classList.add("selected"),this.selectedFilters[n]=r.target.dataset.value,this.handleSearch()})})}async handleSearch(){const e="wine for dish:"+document.getElementById("wine-search-input").value.trim()+";",n=this.selectedFilters,s=[];n.price&&s.push(`price: ${n.price||"any"};`),n.color&&s.push(`color: ${n.color||"any"}; `),n.intensity&&s.push(`intensity: ${n.intensity||"any"}; `);const i=s.length>0?`${e} ${s.join(", ")}`:e;console.log("Searching for:",i),console.log("Applied filters:",n),this.animateCardDisappearance();try{const r=await this.api.getWineRecommendationsSearch(i);r&&r.length>0?(console.log("Recommendations:",r),this.displayResults(r,!0)):(console.log("No recommendations found."),this.displayNoResultsMessage())}catch(r){console.error("Error fetching wine recommendations:",r.message),this.displayErrorMessage()}}displayResults(e,n=!1){const s=document.getElementById("wine-placeholder");this.hideLoadingIndicator(),s.innerHTML="",e.forEach((i,r)=>{r===e.length-1&&this.widgetType==="store"&&(i.isSommSelection=!0),console.log(i);const o=`
|
|
1212
1212
|
<div class="wine-recommendation-tile ${i.isSommSelection?"somm-selection":""}">
|
|
1213
1213
|
${i.isSommSelection?`<div class="somm-selection-badge">${W.translate("wineDetails.sommSelection")}</div>`:""}
|
|
1214
1214
|
${i.image||i.Image?`<img src="${i.image||i.Image}" alt="${i.title||i.Title}" />`:""}
|
package/package.json
CHANGED
package/src/js/widget.js
CHANGED
|
@@ -209,6 +209,10 @@ export class WineWidget {
|
|
|
209
209
|
resultsContainer.innerHTML = '';
|
|
210
210
|
|
|
211
211
|
wines.forEach((wine, index) => {
|
|
212
|
+
if ((index === wines.length - 1) && this.widgetType === 'store') {
|
|
213
|
+
wine['isSommSelection'] = true;
|
|
214
|
+
}
|
|
215
|
+
console.log(wine)
|
|
212
216
|
const wineHTML = `
|
|
213
217
|
<div class="wine-recommendation-tile ${wine.isSommSelection ? 'somm-selection' : ''}">
|
|
214
218
|
${wine.isSommSelection ? `<div class="somm-selection-badge">${translator.translate('wineDetails.sommSelection')}</div>` : ''}
|