dschandra commited on
Commit
ad7067d
·
verified ·
1 Parent(s): 998b660

Update templates/Menu.html

Browse files
Files changed (1) hide show
  1. templates/Menu.html +27 -38
templates/Menu.html CHANGED
@@ -150,46 +150,35 @@
150
  </div>
151
 
152
  <script>
153
- const menuItems = [
154
- { name: "Margherita Pizza", price: "₹299", image: "pizza.jpg", description: "Classic Margherita with fresh basil and mozzarella." },
155
- { name: "Veg Burger", price: "₹149", image: "burger.jpg", description: "Crispy veggie patty with fresh lettuce and tomato." },
156
- { name: "Pasta Alfredo", price: "₹249", image: "pasta.jpg", description: "Creamy Alfredo sauce with penne pasta." },
157
- { name: "French Fries", price: "₹99", image: "fries.jpg", description: "Crispy golden French fries with ketchup." },
158
- { name: "Cold Coffee", price: "₹129", image: "coffee.jpg", description: "Chilled coffee with creamy froth." }
159
- ];
160
 
161
- function loadMenu() {
162
- fetch('/get_menu')
163
- .then(response => response.json())
164
- .then(menuItems => {
165
- const menuContainer = document.getElementById("menu");
166
- menuContainer.innerHTML = "";
167
- menuItems.forEach(item => {
168
- const menuItem = document.createElement("div");
169
- menuItem.classList.add("menu-item");
170
- menuItem.innerHTML = `
171
- <button class="add-btn">ADD</button>
172
- <div class="menu-details">
173
- <h3>${item.name}</h3>
174
- <p>${item.price}</p>
175
- <p>${item.description}</p>
176
- </div>
177
- <img src="${item.image}" alt="${item.name}">
178
- `;
179
- menuContainer.appendChild(menuItem);
180
- });
181
- })
182
- .catch(error => console.error("Error fetching menu:", error));
183
- }
184
 
185
- document.addEventListener("DOMContentLoaded", loadMenu);
 
 
 
 
 
 
186
 
187
-
188
- function logout() {
189
- alert("Logged out successfully!");
190
- }
191
-
192
- document.addEventListener("DOMContentLoaded", loadMenu);
193
- </script>
194
  </body>
195
  </html>
 
150
  </div>
151
 
152
  <script>
153
+ async function loadMenu() {
154
+ const response = await fetch("/get_menu");
155
+ const menuItems = await response.json();
156
+ const menuContainer = document.getElementById("menu");
157
+ menuContainer.innerHTML = "";
 
 
158
 
159
+ menuItems.forEach(item => {
160
+ const menuItem = document.createElement("div");
161
+ menuItem.classList.add("menu-item");
162
+ menuItem.innerHTML = `
163
+ <img src="${item.Image1__c}" alt="${item.Name}">
164
+ <h3>${item.Name}</h3>
165
+ <p>${item.Category__c} - ${item.Section__c}</p>
166
+ <p>Price: ₹${item.Price__c}</p>
167
+ <button class="add-btn" onclick="openModal('${item.Name}', '${item.Image2__c}', '${item.Ingredients__c}', '${item.Price__c}')">ADD</button>
168
+ `;
169
+ menuContainer.appendChild(menuItem);
170
+ });
171
+ }
 
 
 
 
 
 
 
 
 
 
172
 
173
+ function openModal(name, image, ingredients, price) {
174
+ document.getElementById("modalTitle").innerText = name;
175
+ document.getElementById("modalImage").src = image;
176
+ document.getElementById("modalIngredients").innerText = ingredients;
177
+ document.getElementById("modalPrice").innerText = "Price: ₹" + price;
178
+ document.getElementById("menuModal").style.display = "block";
179
+ }
180
 
181
+ document.addEventListener("DOMContentLoaded", loadMenu);
182
+ </script>
 
 
 
 
 
183
  </body>
184
  </html>