lokesh341 commited on
Commit
86b7bfb
·
verified ·
1 Parent(s): 7a88679

Update templates/menu_page.html

Browse files
Files changed (1) hide show
  1. templates/menu_page.html +167 -125
templates/menu_page.html CHANGED
@@ -4,169 +4,211 @@
4
  <head>
5
  <meta charset="UTF-8">
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
- <title>Restaurant Menu</title>
8
  <style>
 
9
  body {
10
  font-family: Arial, sans-serif;
11
- background-color: #f8f9fa;
12
- text-align: center;
13
  margin: 0;
14
- padding: 20px;
 
 
 
 
 
15
  }
16
  h1 {
17
- color: #ff5722;
 
18
  }
19
- .menu-container {
20
- display: flex;
21
- flex-wrap: wrap;
22
- justify-content: center;
23
- margin-top: 20px;
 
 
 
 
 
 
 
 
 
24
  }
 
 
25
  .menu-item {
26
- background: white;
27
- padding: 15px;
28
  margin: 10px;
29
- border-radius: 8px;
30
- box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.1);
31
- width: 300px;
32
- text-align: left;
33
- }
34
- .menu-item h3 {
35
- margin: 0;
36
- color: #333;
37
- }
38
- .menu-item p {
39
- margin: 5px 0;
40
- color: #555;
41
- }
42
- .menu-item button {
43
- background-color: #ff5722;
44
- color: white;
45
- border: none;
46
- padding: 8px;
47
- cursor: pointer;
48
- width: 100%;
49
  border-radius: 5px;
 
50
  }
51
- .menu-item button:hover {
52
- background-color: #e64a19;
 
 
 
53
  }
 
 
54
  .cart-container {
55
  margin-top: 30px;
56
- padding: 15px;
57
- background: white;
58
- border-radius: 8px;
59
- width: 50%;
60
- margin-left: auto;
61
- margin-right: auto;
62
- box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.1);
63
- text-align: left;
64
- }
65
- .cart-container h2 {
66
- text-align: center;
67
- color: #ff5722;
68
  }
69
  .cart-item {
70
  display: flex;
71
  justify-content: space-between;
72
- border-bottom: 1px solid #ddd;
73
- padding: 5px 0;
74
  }
75
- .cart-total {
76
- font-size: 18px;
 
 
 
 
 
 
 
 
 
 
 
 
77
  font-weight: bold;
78
- text-align: right;
79
- margin-top: 10px;
 
 
 
 
 
 
80
  }
81
  </style>
82
  </head>
83
  <body>
84
- <h1>Restaurant Menu</h1>
85
- <div class="menu-container" id="menu-list">
86
- <p>Loading menu...</p>
 
 
 
 
 
87
  </div>
88
 
89
- <div class="cart-container">
90
- <h2>Your Cart</h2>
91
- <div id="cart-list">
92
- <p>No items in cart.</p>
 
93
  </div>
94
- <p class="cart-total" id="cart-total">Total: $0.00</p>
 
 
 
 
 
 
 
 
 
 
 
 
95
  </div>
96
 
97
  <script>
98
- let cart = [];
99
-
100
- function fetchMenu() {
101
- fetch("/menu") // Fetch from Flask API
102
- .then(response => response.json())
103
- .then(data => {
104
- if (data.success) {
105
- let menuContainer = document.getElementById("menu-list");
106
- menuContainer.innerHTML = "";
107
-
108
- data.menu.forEach(item => {
109
- let menuItem = document.createElement("div");
110
- menuItem.classList.add("menu-item");
111
-
112
- menuItem.innerHTML = `
113
- <h3>${item.name}</h3>
114
- <p><strong>Category:</strong> ${item.category}</p>
115
- <p><strong>Price:</strong> $${item.price.toFixed(2)}</p>
116
- <p><strong>Ingredients:</strong> ${item.ingredients}</p>
117
- <button onclick="addToCart('${item.name}', ${item.price})">Add to Cart</button>
118
- `;
119
-
120
- menuContainer.appendChild(menuItem);
121
- });
122
- } else {
123
- document.getElementById("menu-list").innerHTML = "<p>Error loading menu.</p>";
124
- }
125
- })
126
- .catch(error => {
127
- console.error("Error fetching menu:", error);
128
- document.getElementById("menu-list").innerHTML = "<p>Unable to load menu.</p>";
129
- });
130
- }
131
-
132
- function addToCart(name, price) {
133
- cart.push({ name, price });
134
- updateCart();
135
- }
136
-
137
- function updateCart() {
138
- let cartContainer = document.getElementById("cart-list");
139
- let totalContainer = document.getElementById("cart-total");
140
-
141
- if (cart.length === 0) {
142
- cartContainer.innerHTML = "<p>No items in cart.</p>";
143
- totalContainer.innerText = "Total: $0.00";
144
- return;
145
- }
146
 
147
- cartContainer.innerHTML = "";
148
- let total = 0;
149
-
150
- cart.forEach((item, index) => {
151
- total += item.price;
152
- let cartItem = document.createElement("div");
153
- cartItem.classList.add("cart-item");
154
- cartItem.innerHTML = `
155
- <span>${item.name} - $${item.price.toFixed(2)}</span>
156
- <button onclick="removeFromCart(${index})" style="background-color: red; padding: 4px; font-size: 12px;">Remove</button>
157
- `;
158
- cartContainer.appendChild(cartItem);
 
 
 
 
 
 
 
 
 
 
159
  });
 
160
 
161
- totalContainer.innerText = `Total: $${total.toFixed(2)}`;
 
 
 
 
 
 
 
 
 
 
162
  }
163
 
164
- function removeFromCart(index) {
165
- cart.splice(index, 1);
166
- updateCart();
 
 
 
 
 
 
 
 
 
 
 
167
  }
168
 
169
- window.onload = fetchMenu;
 
 
 
 
 
 
 
 
 
170
  </script>
 
171
  </body>
172
  </html>
 
4
  <head>
5
  <meta charset="UTF-8">
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>Biryani Hub Menu</title>
8
  <style>
9
+ /* General Styling */
10
  body {
11
  font-family: Arial, sans-serif;
12
+ background-color: #f8f8f8;
 
13
  margin: 0;
14
+ padding: 0;
15
+ }
16
+ .container {
17
+ max-width: 1200px;
18
+ margin: 50px auto;
19
+ text-align: center;
20
  }
21
  h1 {
22
+ font-size: 2.5rem;
23
+ color: #333;
24
  }
25
+
26
+ /* Menu Buttons */
27
+ .menu-option button {
28
+ font-size: 1.2rem;
29
+ padding: 10px 20px;
30
+ margin: 20px;
31
+ cursor: pointer;
32
+ border: none;
33
+ border-radius: 5px;
34
+ background-color: #007bff;
35
+ color: white;
36
+ }
37
+ .menu-option button:hover {
38
+ background-color: #0056b3;
39
  }
40
+
41
+ /* Menu Items */
42
  .menu-item {
43
+ display: inline-block;
44
+ width: 30%;
45
  margin: 10px;
46
+ padding: 10px;
47
+ border: 1px solid #ddd;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  border-radius: 5px;
49
+ background-color: #fff;
50
  }
51
+ .menu-item img {
52
+ width: 100px;
53
+ height: 100px;
54
+ border-radius: 8px;
55
+ margin-bottom: 10px;
56
  }
57
+
58
+ /* Cart Section */
59
  .cart-container {
60
  margin-top: 30px;
61
+ padding: 10px;
62
+ border: 1px solid #ddd;
63
+ border-radius: 5px;
64
+ background-color: #eaf3e1;
65
+ display: none;
 
 
 
 
 
 
 
66
  }
67
  .cart-item {
68
  display: flex;
69
  justify-content: space-between;
70
+ margin-bottom: 10px;
 
71
  }
72
+
73
+ /* View Cart Button */
74
+ .view-cart-container {
75
+ position: fixed;
76
+ bottom: 20px;
77
+ right: 20px;
78
+ z-index: 999;
79
+ }
80
+ .view-cart-button {
81
+ background-color: #007bff;
82
+ color: #fff;
83
+ padding: 10px 20px;
84
+ border-radius: 50px;
85
+ font-size: 1rem;
86
  font-weight: bold;
87
+ text-decoration: none;
88
+ display: flex;
89
+ align-items: center;
90
+ justify-content: center;
91
+ }
92
+ .view-cart-button:hover {
93
+ background-color: #0056b3;
94
+ text-decoration: none;
95
  }
96
  </style>
97
  </head>
98
  <body>
99
+
100
+ <!-- Welcome Section -->
101
+ <div class="container" id="welcome-container">
102
+ <h1>Welcome to the Biryani Hub Menu</h1>
103
+ <div class="menu-option">
104
+ <button id="veg-btn" onclick="showMenu('veg')">Vegetarian Menu</button>
105
+ <button id="non-veg-btn" onclick="showMenu('nonVeg')">Non-Vegetarian Menu</button>
106
+ </div>
107
  </div>
108
 
109
+ <!-- Menu Section -->
110
+ <div class="container" id="menu-container" style="display: none;">
111
+ <h1>Menu</h1>
112
+ <div id="menu-items" class="row">
113
+ <!-- Menu items will be dynamically added here -->
114
  </div>
115
+ <button onclick="viewCart()">View Cart</button>
116
+ </div>
117
+
118
+ <!-- Cart Section -->
119
+ <div class="cart-container" id="cart-container">
120
+ <h2>Your Cart</h2>
121
+ <div id="cart-items"></div>
122
+ <button onclick="placeOrder()">Place Final Order</button>
123
+ </div>
124
+
125
+ <!-- Floating View Cart Button -->
126
+ <div class="view-cart-container">
127
+ <a href="javascript:void(0);" class="view-cart-button" onclick="viewCart()">View Cart</a>
128
  </div>
129
 
130
  <script>
131
+ // Menu Data
132
+ const menuItems = {
133
+ veg: [
134
+ { name: 'Samosa', price: 9, ingredients: 'Potatoes, Peas, Flour, Spices', description: 'Crispy fried pastry filled with spiced potatoes and peas.', imageUrl: 'https://via.placeholder.com/100' },
135
+ { name: 'Onion Pakoda', price: 10, ingredients: 'Onions, Gram Flour, Spices', description: 'Deep-fried onion fritters seasoned with herbs and spices.', imageUrl: 'https://via.placeholder.com/100' },
136
+ { name: 'Chilli Gobi', price: 12, ingredients: 'Cauliflower, Chili Sauce, Spices', description: 'Cauliflower florets tossed in a spicy chili sauce.', imageUrl: 'https://via.placeholder.com/100' }
137
+ ],
138
+ nonVeg: [
139
+ { name: 'Chicken Biryani', price: 14, ingredients: 'Chicken, Basmati Rice, Spices', description: 'Aromatic basmati rice cooked with tender chicken and spices.', imageUrl: 'https://via.placeholder.com/100' },
140
+ { name: 'Mutton Biryani', price: 16, ingredients: 'Mutton, Basmati Rice, Spices', description: 'Flavorful rice dish made with succulent mutton and aromatic spices.', imageUrl: 'https://via.placeholder.com/100' },
141
+ { name: 'Butter Chicken', price: 15, ingredients: 'Chicken, Tomato, Butter, Cream', description: 'Tender chicken cooked in a rich, creamy tomato sauce.', imageUrl: 'https://via.placeholder.com/100' }
142
+ ]
143
+ };
144
+
145
+ const cart = [];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
 
147
+ // Function to Show Menu
148
+ function showMenu(type) {
149
+ document.getElementById('welcome-container').style.display = 'none';
150
+ document.getElementById('menu-container').style.display = 'block';
151
+ const menuContainer = document.getElementById('menu-items');
152
+ menuContainer.innerHTML = '';
153
+
154
+ menuItems[type].forEach(item => {
155
+ const div = document.createElement('div');
156
+ div.classList.add('menu-item');
157
+ div.innerHTML = `
158
+ <div class="details">
159
+ <img src="${item.imageUrl}" alt="${item.name}">
160
+ <div class="text">
161
+ <h3>${item.name}</h3>
162
+ <p>${item.description}</p>
163
+ <p><strong>Ingredients:</strong> ${item.ingredients}</p>
164
+ <p><strong>Price:</strong> $${item.price}</p>
165
+ <button onclick="addToCart('${item.name}')">Add to Cart</button>
166
+ </div>
167
+ </div>`;
168
+ menuContainer.appendChild(div);
169
  });
170
+ }
171
 
172
+ // Function to Add Items to Cart
173
+ function addToCart(itemName) {
174
+ const quantity = prompt(`How many ${itemName} would you like to add?`, 1);
175
+ if (quantity && !isNaN(quantity) && quantity > 0) {
176
+ const item = menuItems.veg.concat(menuItems.nonVeg).find(item => item.name === itemName);
177
+ const cartItem = { ...item, quantity: parseInt(quantity) };
178
+ cart.push(cartItem);
179
+ alert(`${quantity} of ${itemName} added to your cart.`);
180
+ } else {
181
+ alert("Please enter a valid quantity.");
182
+ }
183
  }
184
 
185
+ // Function to View Cart
186
+ function viewCart() {
187
+ const cartContainer = document.getElementById('cart-container');
188
+ const cartItemsContainer = document.getElementById('cart-items');
189
+ cartItemsContainer.innerHTML = '';
190
+
191
+ cart.forEach(cartItem => {
192
+ const div = document.createElement('div');
193
+ div.classList.add('cart-item');
194
+ div.innerHTML = `<span>${cartItem.name} (x${cartItem.quantity}) - $${cartItem.price * cartItem.quantity}</span>`;
195
+ cartItemsContainer.appendChild(div);
196
+ });
197
+
198
+ cartContainer.style.display = 'block';
199
  }
200
 
201
+ // Function to Place Order
202
+ function placeOrder() {
203
+ if (cart.length > 0) {
204
+ alert("Your order has been placed successfully!");
205
+ cart.length = 0;
206
+ viewCart();
207
+ } else {
208
+ alert("Your cart is empty. Please add items before placing the order.");
209
+ }
210
+ }
211
  </script>
212
+
213
  </body>
214
  </html>