Spaces:
Running
Running
Update static/script.js
Browse files- static/script.js +3 -8
static/script.js
CHANGED
@@ -134,7 +134,7 @@ function updateSelectionBox() {
|
|
134 |
|
135 |
chatMessages.appendChild(selectionBox);
|
136 |
chatMessages.scrollTop = chatMessages.scrollHeight;
|
137 |
-
console.log('
|
138 |
}
|
139 |
|
140 |
function handleResponse(userInput) {
|
@@ -230,12 +230,11 @@ function displaySuggestions(items) {
|
|
230 |
};
|
231 |
suggestionBox.appendChild(suggestionItem);
|
232 |
});
|
233 |
-
suggestionBox.style.display = 'block';
|
234 |
}
|
235 |
|
236 |
function removeSuggestions() {
|
237 |
const suggestionBox = document.getElementById('suggestionBox');
|
238 |
-
if (suggestionBox) suggestionBox.
|
239 |
}
|
240 |
|
241 |
function fetchItemDetails(itemName) {
|
@@ -300,7 +299,6 @@ function fetchSectorItemDetails(itemName) {
|
|
300 |
addMessage('bot', `Sorry, I couldn’t find "${itemName}" in Sector_Detail__c. Try another item!`);
|
301 |
} else {
|
302 |
const details = data.item_details;
|
303 |
-
console.log('Fetched sector item details:', details);
|
304 |
if (selectedItems.some(item => item.name === details.name)) {
|
305 |
addMessage('bot', `"${details.name}" is already in your selection!`);
|
306 |
} else {
|
@@ -459,10 +457,9 @@ function submitToSalesforce() {
|
|
459 |
|
460 |
const itemsToSubmit = selectedItems.map(item => ({
|
461 |
name: item.name,
|
462 |
-
category: item.category || 'Unknown',
|
463 |
description: item.description || 'No description available'
|
464 |
}));
|
465 |
-
console.log('Items being submitted to Salesforce:', itemsToSubmit);
|
466 |
|
467 |
fetch('/submit_items', {
|
468 |
method: 'POST',
|
@@ -473,7 +470,6 @@ function submitToSalesforce() {
|
|
473 |
.then(data => {
|
474 |
if (data.error) {
|
475 |
addMessage('bot', `Uh-oh! Failed to submit items: ${data.error}. Want to try again?`);
|
476 |
-
console.error('Submission error:', data.error);
|
477 |
} else {
|
478 |
addMessage('bot', `${data.success}! Your culinary choices are now saved. What’s next on the menu?`);
|
479 |
selectedItems = [];
|
@@ -482,7 +478,6 @@ function submitToSalesforce() {
|
|
482 |
})
|
483 |
.catch(error => {
|
484 |
addMessage('bot', `Error submitting items: ${error.message}. I’ll retry shortly...`);
|
485 |
-
console.error('Submission error:', error.message);
|
486 |
setTimeout(submitToSalesforce, 2000);
|
487 |
});
|
488 |
}
|
|
|
134 |
|
135 |
chatMessages.appendChild(selectionBox);
|
136 |
chatMessages.scrollTop = chatMessages.scrollHeight;
|
137 |
+
console.log('Updated selection box with items:', selectedItems.map(item => item.name));
|
138 |
}
|
139 |
|
140 |
function handleResponse(userInput) {
|
|
|
230 |
};
|
231 |
suggestionBox.appendChild(suggestionItem);
|
232 |
});
|
|
|
233 |
}
|
234 |
|
235 |
function removeSuggestions() {
|
236 |
const suggestionBox = document.getElementById('suggestionBox');
|
237 |
+
if (suggestionBox) suggestionBox.innerHTML = '';
|
238 |
}
|
239 |
|
240 |
function fetchItemDetails(itemName) {
|
|
|
299 |
addMessage('bot', `Sorry, I couldn’t find "${itemName}" in Sector_Detail__c. Try another item!`);
|
300 |
} else {
|
301 |
const details = data.item_details;
|
|
|
302 |
if (selectedItems.some(item => item.name === details.name)) {
|
303 |
addMessage('bot', `"${details.name}" is already in your selection!`);
|
304 |
} else {
|
|
|
457 |
|
458 |
const itemsToSubmit = selectedItems.map(item => ({
|
459 |
name: item.name,
|
460 |
+
category: item.category || 'Unknown',
|
461 |
description: item.description || 'No description available'
|
462 |
}));
|
|
|
463 |
|
464 |
fetch('/submit_items', {
|
465 |
method: 'POST',
|
|
|
470 |
.then(data => {
|
471 |
if (data.error) {
|
472 |
addMessage('bot', `Uh-oh! Failed to submit items: ${data.error}. Want to try again?`);
|
|
|
473 |
} else {
|
474 |
addMessage('bot', `${data.success}! Your culinary choices are now saved. What’s next on the menu?`);
|
475 |
selectedItems = [];
|
|
|
478 |
})
|
479 |
.catch(error => {
|
480 |
addMessage('bot', `Error submitting items: ${error.message}. I’ll retry shortly...`);
|
|
|
481 |
setTimeout(submitToSalesforce, 2000);
|
482 |
});
|
483 |
}
|