Spaces:
Sleeping
Sleeping
Update static/script.js
Browse files- static/script.js +21 -9
static/script.js
CHANGED
@@ -96,7 +96,7 @@ function updateSelectionBox() {
|
|
96 |
if (e.key === 'Enter' && textInput.value.trim()) {
|
97 |
const manualItem = {
|
98 |
name: textInput.value.trim(),
|
99 |
-
image_url: ''
|
100 |
};
|
101 |
selectedItems.push(manualItem);
|
102 |
addMessage('bot', `Added "${manualItem.name}" to your selection! Check the box below.`);
|
@@ -230,14 +230,28 @@ function displayItemsList(items, containerId, isSectorDetail = false) {
|
|
230 |
items.forEach(item => {
|
231 |
const itemDiv = document.createElement('div');
|
232 |
itemDiv.className = containerId === 'menuItemsList' ? 'ingredient-item' : 'suggestion-item';
|
|
|
233 |
const img = document.createElement('img');
|
234 |
img.src = item.image_url || 'https://via.placeholder.com/60';
|
235 |
img.alt = item.name;
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
const button = document.createElement('button');
|
242 |
button.textContent = 'Add';
|
243 |
button.onclick = () => {
|
@@ -253,9 +267,8 @@ function displayItemsList(items, containerId, isSectorDetail = false) {
|
|
253 |
}
|
254 |
updateSelectionBox();
|
255 |
};
|
256 |
-
itemDiv.appendChild(img);
|
257 |
-
itemDiv.appendChild(name);
|
258 |
itemDiv.appendChild(button);
|
|
|
259 |
container.appendChild(itemDiv);
|
260 |
});
|
261 |
}
|
@@ -300,7 +313,6 @@ function submitToSalesforce() {
|
|
300 |
return;
|
301 |
}
|
302 |
|
303 |
-
// Only send the name field to the backend
|
304 |
const itemsToSubmit = selectedItems.map(item => ({ name: item.name }));
|
305 |
|
306 |
fetch('/submit_items', {
|
|
|
96 |
if (e.key === 'Enter' && textInput.value.trim()) {
|
97 |
const manualItem = {
|
98 |
name: textInput.value.trim(),
|
99 |
+
image_url: ''
|
100 |
};
|
101 |
selectedItems.push(manualItem);
|
102 |
addMessage('bot', `Added "${manualItem.name}" to your selection! Check the box below.`);
|
|
|
230 |
items.forEach(item => {
|
231 |
const itemDiv = document.createElement('div');
|
232 |
itemDiv.className = containerId === 'menuItemsList' ? 'ingredient-item' : 'suggestion-item';
|
233 |
+
|
234 |
const img = document.createElement('img');
|
235 |
img.src = item.image_url || 'https://via.placeholder.com/60';
|
236 |
img.alt = item.name;
|
237 |
+
itemDiv.appendChild(img);
|
238 |
+
|
239 |
+
const nameDiv = document.createElement('div');
|
240 |
+
nameDiv.textContent = item.name;
|
241 |
+
nameDiv.style.textAlign = 'center';
|
242 |
+
nameDiv.style.marginTop = '5px';
|
243 |
+
nameDiv.style.fontSize = '12px';
|
244 |
+
itemDiv.appendChild(nameDiv);
|
245 |
+
|
246 |
+
if (isSectorDetail && item.description) {
|
247 |
+
const descDiv = document.createElement('div');
|
248 |
+
descDiv.textContent = item.description;
|
249 |
+
descDiv.style.textAlign = 'center';
|
250 |
+
descDiv.style.fontSize = '10px';
|
251 |
+
descDiv.style.color = '#555';
|
252 |
+
itemDiv.appendChild(descDiv);
|
253 |
+
}
|
254 |
+
|
255 |
const button = document.createElement('button');
|
256 |
button.textContent = 'Add';
|
257 |
button.onclick = () => {
|
|
|
267 |
}
|
268 |
updateSelectionBox();
|
269 |
};
|
|
|
|
|
270 |
itemDiv.appendChild(button);
|
271 |
+
|
272 |
container.appendChild(itemDiv);
|
273 |
});
|
274 |
}
|
|
|
313 |
return;
|
314 |
}
|
315 |
|
|
|
316 |
const itemsToSubmit = selectedItems.map(item => ({ name: item.name }));
|
317 |
|
318 |
fetch('/submit_items', {
|