lokesh341 commited on
Commit
087584b
·
verified ·
1 Parent(s): a64ad00

Update templates/menu_page.html

Browse files
Files changed (1) hide show
  1. templates/menu_page.html +180 -156
templates/menu_page.html CHANGED
@@ -3,205 +3,229 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Biryani Hub</title>
 
7
  <style>
 
8
  body {
9
  font-family: Arial, sans-serif;
10
- background-color: #f8f8f8;
11
  margin: 0;
12
  padding: 0;
13
  }
14
- .menu-container, .cart-container {
15
- max-width: 1200px;
16
- margin: 0 auto;
17
- padding: 20px;
18
- background-color: #4169E1;
19
- box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
20
- border-radius: 8px;
21
- margin-top: 50px;
 
 
 
 
 
 
22
  }
23
- h1 {
 
24
  text-align: center;
25
- font-size: 2.5rem;
26
- color: #87CEFA;
27
- margin-bottom: 30px;
28
  }
29
- button {
30
- padding: 10px 20px;
31
- background-color: orange;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  color: white;
33
  border: none;
34
  border-radius: 5px;
35
  cursor: pointer;
36
- font-size: 2.2rem;
37
- margin: 10px 0;
38
- }
39
- button:hover {
40
- background-color: #FF7F00;
41
  }
42
- .menu-item, .cart-item {
43
- border-bottom: 1px solid #eee;
44
- padding: 15px 0;
45
- display: flex;
46
- justify-content: space-between;
47
- align-items: center;
48
  }
49
- .order-btn {
50
- padding: 10px 20px;
51
- background-color: #4CAF50;
 
52
  color: white;
53
  border: none;
54
  border-radius: 5px;
 
 
55
  cursor: pointer;
 
56
  }
57
- .order-btn:hover {
58
- background-color: #45a049;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  }
60
  </style>
61
  </head>
62
  <body>
63
 
64
- <!-- Page 1: Welcome Page -->
65
- <div class="menu-container" id="welcome-page">
66
- <h1>Welcome to Biryani Hub Menu</h1>
67
- <h3>Please choose a category:</h3>
68
- <button id="main-course-btn">Main Course</button>
69
- <button id="appetizer-btn">Appetizers</button>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  </div>
71
 
72
- <!-- Page 2: Menu Page -->
73
- <div class="menu-container" id="menu-page" style="display: none;">
74
- <h1 id="menu-title"></h1>
75
- <div id="menu-items"></div>
76
- <button class="order-btn" onclick="goToCart()">Go to Cart</button>
77
  </div>
78
 
79
- <!-- Page 3: Cart Page -->
80
- <div class="cart-container" id="cart-page" style="display: none;">
81
- <h1>Your Cart</h1>
82
- <div id="cart-items"></div>
83
- <button class="order-btn" onclick="placeOrder()">Place Order</button>
 
 
 
 
 
84
  </div>
85
 
86
- <script>
87
- // Speech synthesis setup
88
- const synth = window.speechSynthesis;
89
- const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
90
- recognition.lang = "en-US";
91
- recognition.interimResults = false;
92
-
93
- function speak(text) {
94
- const msg = new SpeechSynthesisUtterance(text);
95
- synth.speak(msg);
96
- }
97
-
98
- // Automatically speak out the options on page load
99
- window.onload = function() {
100
- speak("Welcome to Biryani Hub! We have the following categories: Main Course and Appetizers. Please say 'Main Course' or 'Appetizers' to select a category.");
101
- recognition.start();
102
- };
103
-
104
- // Listen for voice commands
105
- recognition.onresult = (event) => {
106
- const categoryCommand = event.results[0][0].transcript.toLowerCase();
107
- if (categoryCommand.includes("main course")) {
108
- window.location.href = '/menu?category=Main%20Course';
109
- } else if (categoryCommand.includes("appetizers")) {
110
- window.location.href = '/menu?category=Appetizers';
111
- } else {
112
- speak("Sorry, I didn't understand that. Please say 'Main Course' or 'Appetizers'.");
113
- }
114
- };
115
-
116
- // Sample menu data
117
- const menuData = {
118
- 'Main Course': [
119
- { name: "Chicken Biryani", price: 250 },
120
- { name: "Veg Biryani", price: 200 },
121
- { name: "Mutton Biryani", price: 300 }
122
- ],
123
- 'Appetizers': [
124
- { name: "Paneer Tikka", price: 180 },
125
- { name: "Chicken Wings", price: 220 }
126
- ]
127
- };
128
 
 
 
129
  let cart = [];
130
 
131
- // Show the menu based on category selection
132
- const urlParams = new URLSearchParams(window.location.search);
133
- const category = urlParams.get('category') || 'Main Course';
134
-
135
- document.getElementById("menu-title").textContent = category + " Menu";
136
- const menuItemsContainer = document.getElementById("menu-items");
137
-
138
- menuData[category].forEach(item => {
139
- const itemDiv = document.createElement('div');
140
- itemDiv.classList.add('menu-item');
141
- itemDiv.innerHTML = `
142
- <div>
143
- <h3>${item.name}</h3>
144
- <p>Price: ₹${item.price}</p>
145
- </div>
146
- <button class="order-btn" onclick="addToCart('${item.name}', ${item.price})">Add to Cart</button>
147
- `;
148
- menuItemsContainer.appendChild(itemDiv);
149
- });
150
-
151
- // Add items to the cart
152
- function addToCart(name, price) {
153
- cart.push({ name, price });
154
- alert(`${name} added to cart!`);
155
- }
156
-
157
- // Navigate to the cart page
158
- function goToCart() {
159
- document.getElementById("welcome-page").style.display = "none";
160
- document.getElementById("menu-page").style.display = "none";
161
- document.getElementById("cart-page").style.display = "block";
162
- populateCart();
163
- }
164
-
165
- // Populate the cart with items
166
- function populateCart() {
167
- const cartItemsContainer = document.getElementById("cart-items");
168
  if (cart.length === 0) {
169
- cartItemsContainer.innerHTML = "<p>Your cart is empty.</p>";
170
- } else {
171
- cart.forEach(item => {
172
- const itemDiv = document.createElement("div");
173
- itemDiv.classList.add("cart-item");
174
- itemDiv.innerHTML = `
175
- <div>
176
- <h3>${item.name}</h3>
177
- <p>Price: ₹${item.price}</p>
178
- </div>
179
- `;
180
- cartItemsContainer.appendChild(itemDiv);
181
- });
182
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  }
184
 
185
- // Place the order (dummy function)
186
  function placeOrder() {
187
- const orderData = {
188
- items: cart.map(item => ({
189
- name: item.name,
190
- price: item.price,
191
- quantity: 1
192
- }))
193
- };
194
-
195
- fetch("/order", {
196
- method: "POST",
197
  headers: {
198
- "Content-Type": "application/json"
199
  },
200
- body: JSON.stringify(orderData)
201
  })
202
  .then(response => response.json())
203
- .then(data => alert(data.message))
204
- .catch(error => alert("There was an error placing your order"));
 
 
 
 
 
 
 
205
  }
206
  </script>
207
 
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Menu Page</title>
7
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
8
  <style>
9
+ /* Basic Styles */
10
  body {
11
  font-family: Arial, sans-serif;
12
+ background-color: #f4f4f4;
13
  margin: 0;
14
  padding: 0;
15
  }
16
+
17
+ header {
18
+ background-color: #333;
19
+ color: white;
20
+ padding: 15px;
21
+ text-align: center;
22
+ }
23
+
24
+ .menu-container {
25
+ margin: 20px;
26
+ }
27
+
28
+ .menu-category {
29
+ margin-bottom: 20px;
30
  }
31
+
32
+ .menu-category h2 {
33
  text-align: center;
34
+ font-size: 24px;
 
 
35
  }
36
+
37
+ .menu-item {
38
+ background-color: white;
39
+ padding: 10px;
40
+ margin-bottom: 10px;
41
+ border-radius: 5px;
42
+ box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1);
43
+ display: flex;
44
+ justify-content: space-between;
45
+ align-items: center;
46
+ }
47
+
48
+ .menu-item h3 {
49
+ margin: 0;
50
+ font-size: 20px;
51
+ }
52
+
53
+ .menu-item p {
54
+ margin: 0;
55
+ font-size: 16px;
56
+ color: #888;
57
+ }
58
+
59
+ .menu-item button {
60
+ padding: 8px 12px;
61
+ background-color: #28a745;
62
  color: white;
63
  border: none;
64
  border-radius: 5px;
65
  cursor: pointer;
 
 
 
 
 
66
  }
67
+
68
+ .menu-item button:hover {
69
+ background-color: #218838;
 
 
 
70
  }
71
+
72
+ .cart-button {
73
+ padding: 12px 20px;
74
+ background-color: #007bff;
75
  color: white;
76
  border: none;
77
  border-radius: 5px;
78
+ text-align: center;
79
+ font-size: 18px;
80
  cursor: pointer;
81
+ width: 100%;
82
  }
83
+
84
+ .cart-button:hover {
85
+ background-color: #0056b3;
86
+ }
87
+
88
+ .cart-icon {
89
+ margin-right: 8px;
90
+ }
91
+
92
+ footer {
93
+ text-align: center;
94
+ padding: 10px;
95
+ background-color: #333;
96
+ color: white;
97
+ position: fixed;
98
+ width: 100%;
99
+ bottom: 0;
100
+ }
101
+
102
+ .cart-summary {
103
+ display: flex;
104
+ justify-content: space-between;
105
+ margin-top: 20px;
106
+ }
107
+
108
+ .cart-summary span {
109
+ font-size: 18px;
110
+ font-weight: bold;
111
+ }
112
+
113
+ .cart-summary button {
114
+ background-color: #28a745;
115
  }
116
  </style>
117
  </head>
118
  <body>
119
 
120
+ <!-- Header -->
121
+ <header>
122
+ <h1>Welcome to Our Restaurant</h1>
123
+ </header>
124
+
125
+ <!-- Menu Content -->
126
+ <div class="menu-container">
127
+ {% for category, items in menu_data.items() %}
128
+ <div class="menu-category">
129
+ <h2>{{ category }}</h2>
130
+ {% for item in items %}
131
+ <div class="menu-item">
132
+ <div>
133
+ <h3>{{ item.name }}</h3>
134
+ <p>Price: ₹{{ item.price }}</p>
135
+ </div>
136
+ <button onclick="addToCart('{{ item.name }}', {{ item.price }})">Add to Cart</button>
137
+ </div>
138
+ {% endfor %}
139
+ </div>
140
+ {% endfor %}
141
  </div>
142
 
143
+ <!-- Cart Button -->
144
+ <div class="menu-category">
145
+ <button class="cart-button" onclick="showCart()">
146
+ <i class="fas fa-shopping-cart cart-icon"></i> View Cart
147
+ </button>
148
  </div>
149
 
150
+ <!-- Cart Summary (hidden initially) -->
151
+ <div id="cart-summary" class="order-summary" style="display:none;">
152
+ <h3>Your Cart</h3>
153
+ <ul id="cart-items-list">
154
+ <!-- Cart items will be dynamically listed here -->
155
+ </ul>
156
+ <div class="cart-summary">
157
+ <span>Total: ₹<span id="total-price">0</span></span>
158
+ <button onclick="placeOrder()">Place Order</button>
159
+ </div>
160
  </div>
161
 
162
+ <!-- Footer -->
163
+ <footer>
164
+ <p>Restaurant &copy; 2025</p>
165
+ </footer>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
 
167
+ <!-- JavaScript -->
168
+ <script>
169
  let cart = [];
170
 
171
+ // Add item to cart
172
+ function addToCart(itemName, itemPrice) {
173
+ cart.push({ name: itemName, price: itemPrice });
174
+ alert(`${itemName} added to cart!`);
175
+ }
176
+
177
+ // Show cart and order summary
178
+ function showCart() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  if (cart.length === 0) {
180
+ alert("Your cart is empty!");
181
+ return;
 
 
 
 
 
 
 
 
 
 
 
182
  }
183
+
184
+ // Update cart items list
185
+ const cartItemsList = document.getElementById('cart-items-list');
186
+ cartItemsList.innerHTML = '';
187
+
188
+ let totalPrice = 0;
189
+
190
+ cart.forEach(item => {
191
+ const li = document.createElement('li');
192
+ li.innerHTML = `${item.name} - ₹${item.price}`;
193
+ cartItemsList.appendChild(li);
194
+ totalPrice += item.price;
195
+ });
196
+
197
+ // Update total price
198
+ document.getElementById('total-price').textContent = totalPrice;
199
+
200
+ // Show cart summary
201
+ document.getElementById('cart-summary').style.display = 'block';
202
  }
203
 
204
+ // Place the order
205
  function placeOrder() {
206
+ if (cart.length === 0) {
207
+ alert("Your cart is empty, cannot place the order.");
208
+ return;
209
+ }
210
+
211
+ // Send the order to the backend (POST request)
212
+ fetch('/order', {
213
+ method: 'POST',
 
 
214
  headers: {
215
+ 'Content-Type': 'application/json',
216
  },
217
+ body: JSON.stringify({ cart: cart })
218
  })
219
  .then(response => response.json())
220
+ .then(data => {
221
+ alert(data.message);
222
+ cart = []; // Clear cart after placing the order
223
+ document.getElementById('cart-summary').style.display = 'none'; // Hide cart summary
224
+ })
225
+ .catch(error => {
226
+ console.error('Error:', error);
227
+ alert('Error placing order');
228
+ });
229
  }
230
  </script>
231