Spaces:
Build error
Build error
Update static/script.js
Browse files- static/script.js +15 -6
static/script.js
CHANGED
|
@@ -90,20 +90,29 @@ function fetchNewStepIngredients() {
|
|
| 90 |
if (data.error) {
|
| 91 |
addMessage('bot', `Sorry, there was an error fetching ingredients: ${data.error}`);
|
| 92 |
} else {
|
|
|
|
|
|
|
|
|
|
| 93 |
const ingredients = data.ingredients || [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
addMessage('bot', 'Please select ingredients to add to your dish:');
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
//
|
| 100 |
-
|
| 101 |
}
|
| 102 |
})
|
| 103 |
.catch(error => {
|
| 104 |
addMessage('bot', `Error: Unable to connect to the ingredient database. ${error.message}`);
|
| 105 |
});
|
| 106 |
}
|
|
|
|
| 107 |
function displayIngredientsWithoutSubmit(ingredients) {
|
| 108 |
const chatMessages = document.getElementById('chatMessages');
|
| 109 |
if (!chatMessages) {
|
|
|
|
| 90 |
if (data.error) {
|
| 91 |
addMessage('bot', `Sorry, there was an error fetching ingredients: ${data.error}`);
|
| 92 |
} else {
|
| 93 |
+
// Log the data to check its structure
|
| 94 |
+
console.log('Fetched ingredients data:', data);
|
| 95 |
+
|
| 96 |
const ingredients = data.ingredients || [];
|
| 97 |
+
if (ingredients.length === 0) {
|
| 98 |
+
addMessage('bot', 'No ingredients found. Please try again later.');
|
| 99 |
+
return;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
addMessage('bot', 'Please select ingredients to add to your dish:');
|
| 103 |
+
|
| 104 |
+
// Call the new function to display ingredients without the Submit button for the menu item
|
| 105 |
+
displayMenuItemIngredientsWithoutSubmit(selectedMenuItem); // Show ingredients for the selected menu item
|
| 106 |
+
|
| 107 |
+
// Optionally, you can display the selected ingredients or show the customization input
|
| 108 |
+
displayCustomizationInput(); // Show the customization input box below the ingredients
|
| 109 |
}
|
| 110 |
})
|
| 111 |
.catch(error => {
|
| 112 |
addMessage('bot', `Error: Unable to connect to the ingredient database. ${error.message}`);
|
| 113 |
});
|
| 114 |
}
|
| 115 |
+
|
| 116 |
function displayIngredientsWithoutSubmit(ingredients) {
|
| 117 |
const chatMessages = document.getElementById('chatMessages');
|
| 118 |
if (!chatMessages) {
|