Spaces:
Build error
Build error
Update static/script.js
Browse files- static/script.js +7 -4
static/script.js
CHANGED
|
@@ -144,7 +144,7 @@ function displayCustomizationIngredients(ingredients) {
|
|
| 144 |
// Show the selected menu item
|
| 145 |
const itemName = document.createElement('div');
|
| 146 |
itemName.className = 'menu-item-name';
|
| 147 |
-
itemName.textContent = selectedMenuItem.name;
|
| 148 |
selectedItemDiv.appendChild(itemName);
|
| 149 |
|
| 150 |
const itemImage = document.createElement('img');
|
|
@@ -160,7 +160,7 @@ function displayCustomizationIngredients(ingredients) {
|
|
| 160 |
// Append selected menu item to the ingredient list container
|
| 161 |
ingredientsList.appendChild(selectedItemDiv);
|
| 162 |
|
| 163 |
-
// **Display New Ingredients Below the Menu Item**
|
| 164 |
ingredients.forEach(ingredient => {
|
| 165 |
const item = document.createElement('div');
|
| 166 |
item.className = 'ingredient-item';
|
|
@@ -175,8 +175,10 @@ function displayCustomizationIngredients(ingredients) {
|
|
| 175 |
const button = document.createElement('button');
|
| 176 |
button.textContent = 'Add';
|
| 177 |
button.onclick = () => {
|
| 178 |
-
|
| 179 |
-
|
|
|
|
|
|
|
| 180 |
displaySelectedCustomizationIngredients();
|
| 181 |
}
|
| 182 |
};
|
|
@@ -190,6 +192,7 @@ function displayCustomizationIngredients(ingredients) {
|
|
| 190 |
|
| 191 |
|
| 192 |
|
|
|
|
| 193 |
function displaySelectedCustomizationIngredients() {
|
| 194 |
const chatMessages = document.getElementById('chatMessages');
|
| 195 |
if (!chatMessages) {
|
|
|
|
| 144 |
// Show the selected menu item
|
| 145 |
const itemName = document.createElement('div');
|
| 146 |
itemName.className = 'menu-item-name';
|
| 147 |
+
itemName.textContent = selectedMenuItem.name; // Show the menu item name (e.g., "Paneer Biryani")
|
| 148 |
selectedItemDiv.appendChild(itemName);
|
| 149 |
|
| 150 |
const itemImage = document.createElement('img');
|
|
|
|
| 160 |
// Append selected menu item to the ingredient list container
|
| 161 |
ingredientsList.appendChild(selectedItemDiv);
|
| 162 |
|
| 163 |
+
// **Display New Ingredients Below the Menu Item**
|
| 164 |
ingredients.forEach(ingredient => {
|
| 165 |
const item = document.createElement('div');
|
| 166 |
item.className = 'ingredient-item';
|
|
|
|
| 175 |
const button = document.createElement('button');
|
| 176 |
button.textContent = 'Add';
|
| 177 |
button.onclick = () => {
|
| 178 |
+
// Instead of the ingredient name, show the selected menu item name
|
| 179 |
+
const addedIngredient = selectedMenuItem.name + " with " + ingredient.name;
|
| 180 |
+
if (!selectedIngredients.some(item => item.name === addedIngredient)) {
|
| 181 |
+
selectedIngredients.push({ name: addedIngredient, image_url: ingredient.image_url });
|
| 182 |
displaySelectedCustomizationIngredients();
|
| 183 |
}
|
| 184 |
};
|
|
|
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
+
|
| 196 |
function displaySelectedCustomizationIngredients() {
|
| 197 |
const chatMessages = document.getElementById('chatMessages');
|
| 198 |
if (!chatMessages) {
|