Spaces:
Build error
Build error
Update static/script.js
Browse files- static/script.js +6 -10
static/script.js
CHANGED
|
@@ -71,7 +71,6 @@ function updateSelectionBox() {
|
|
| 71 |
label.textContent = 'Selected Items:';
|
| 72 |
selectionBox.appendChild(label);
|
| 73 |
|
| 74 |
-
// Display selected items with images
|
| 75 |
selectedItems.forEach(item => {
|
| 76 |
const itemContainer = document.createElement('div');
|
| 77 |
itemContainer.className = 'selected-item';
|
|
@@ -97,10 +96,7 @@ function updateSelectionBox() {
|
|
| 97 |
if (e.key === 'Enter' && textInput.value.trim()) {
|
| 98 |
const manualItem = {
|
| 99 |
name: textInput.value.trim(),
|
| 100 |
-
|
| 101 |
-
ingredients: 'Not specified',
|
| 102 |
-
image_url: '', // Default to empty; will use placeholder
|
| 103 |
-
category: 'Both'
|
| 104 |
};
|
| 105 |
selectedItems.push(manualItem);
|
| 106 |
addMessage('bot', `Added "${manualItem.name}" to your selection! Check the box below.`);
|
|
@@ -248,10 +244,7 @@ function displayItemsList(items, containerId, isSectorDetail = false) {
|
|
| 248 |
if (isSectorDetail) {
|
| 249 |
const sectorItem = {
|
| 250 |
name: item.name,
|
| 251 |
-
|
| 252 |
-
ingredients: 'Not specified',
|
| 253 |
-
image_url: item.image_url || '',
|
| 254 |
-
category: item.category || 'Both'
|
| 255 |
};
|
| 256 |
selectedItems.push(sectorItem);
|
| 257 |
addMessage('bot', `Added "${item.name}" to your selection! Check the box below.`);
|
|
@@ -307,10 +300,13 @@ function submitToSalesforce() {
|
|
| 307 |
return;
|
| 308 |
}
|
| 309 |
|
|
|
|
|
|
|
|
|
|
| 310 |
fetch('/submit_items', {
|
| 311 |
method: 'POST',
|
| 312 |
headers: { 'Content-Type': 'application/json' },
|
| 313 |
-
body: JSON.stringify({ items:
|
| 314 |
})
|
| 315 |
.then(response => response.json())
|
| 316 |
.then(data => {
|
|
|
|
| 71 |
label.textContent = 'Selected Items:';
|
| 72 |
selectionBox.appendChild(label);
|
| 73 |
|
|
|
|
| 74 |
selectedItems.forEach(item => {
|
| 75 |
const itemContainer = document.createElement('div');
|
| 76 |
itemContainer.className = 'selected-item';
|
|
|
|
| 96 |
if (e.key === 'Enter' && textInput.value.trim()) {
|
| 97 |
const manualItem = {
|
| 98 |
name: textInput.value.trim(),
|
| 99 |
+
image_url: '' // Default to placeholder
|
|
|
|
|
|
|
|
|
|
| 100 |
};
|
| 101 |
selectedItems.push(manualItem);
|
| 102 |
addMessage('bot', `Added "${manualItem.name}" to your selection! Check the box below.`);
|
|
|
|
| 244 |
if (isSectorDetail) {
|
| 245 |
const sectorItem = {
|
| 246 |
name: item.name,
|
| 247 |
+
image_url: item.image_url || ''
|
|
|
|
|
|
|
|
|
|
| 248 |
};
|
| 249 |
selectedItems.push(sectorItem);
|
| 250 |
addMessage('bot', `Added "${item.name}" to your selection! Check the box below.`);
|
|
|
|
| 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', {
|
| 307 |
method: 'POST',
|
| 308 |
headers: { 'Content-Type': 'application/json' },
|
| 309 |
+
body: JSON.stringify({ items: itemsToSubmit })
|
| 310 |
})
|
| 311 |
.then(response => response.json())
|
| 312 |
.then(data => {
|