lokesh341 commited on
Commit
d42f6ff
·
verified ·
1 Parent(s): b2aa51e

Update templates/menu_page.html

Browse files
Files changed (1) hide show
  1. templates/menu_page.html +67 -194
templates/menu_page.html CHANGED
@@ -67,6 +67,42 @@
67
  border-radius: 4px;
68
  border: 1px solid #ccc;
69
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  </style>
71
  </head>
72
  <body>
@@ -125,201 +161,38 @@
125
  <button id="back-to-cart-btn" class="order-btn">Back to Cart</button>
126
  </div>
127
 
128
- <script>
129
- // Sample menu data
130
- const menuData = {
131
- 'Main Course': [
132
- { name: "Chicken Biryani", price: 250 },
133
- { name: "Veg Biryani", price: 200 },
134
- { name: "Mutton Biryani", price: 300 }
135
- ],
136
- 'Appetizers': [
137
- { name: "Paneer Tikka", price: 180 },
138
- { name: "Chicken Wings", price: 220 }
139
- ]
140
- };
141
-
142
- // Initialize cart as an empty array
143
- let cart = [];
144
-
145
- // Select page elements
146
- const categoryPage = document.getElementById('page1');
147
- const mainCoursePage = document.getElementById('main-course-page');
148
- const appetizerPage = document.getElementById('appetizer-page');
149
- const cartPage = document.getElementById('cart-page');
150
- const orderPage = document.getElementById('order-page');
151
-
152
- // Category selection event listeners
153
- document.getElementById("main-course-btn").addEventListener("click", () => {
154
- categoryPage.style.display = "none";
155
- mainCoursePage.style.display = "block";
156
- displayMenuItems('Main Course');
157
- });
158
-
159
- document.getElementById("appetizer-btn").addEventListener("click", () => {
160
- categoryPage.style.display = "none";
161
- appetizerPage.style.display = "block";
162
- displayMenuItems('Appetizers');
163
- });
164
-
165
- // Back to category selection buttons
166
- document.getElementById("back-to-category-btn").addEventListener("click", () => {
167
- mainCoursePage.style.display = "none";
168
- categoryPage.style.display = "block";
169
- });
170
- document.getElementById("back-to-category-btn2").addEventListener("click", () => {
171
- appetizerPage.style.display = "none";
172
- categoryPage.style.display = "block";
173
- });
174
-
175
- // View Cart buttons
176
- document.getElementById("view-cart-btn1").addEventListener("click", () => {
177
- mainCoursePage.style.display = "none";
178
- cartPage.style.display = "block";
179
- displayCartItems();
180
- });
181
- document.getElementById("view-cart-btn2").addEventListener("click", () => {
182
- appetizerPage.style.display = "none";
183
- cartPage.style.display = "block";
184
- displayCartItems();
185
- });
186
-
187
- // Navigation from Cart page
188
- document.getElementById("back-to-menu-btn").addEventListener("click", () => {
189
- cartPage.style.display = "none";
190
- categoryPage.style.display = "block";
191
- });
192
-
193
- document.getElementById("proceed-order-btn").addEventListener("click", () => {
194
- cartPage.style.display = "none";
195
- orderPage.style.display = "block";
196
- });
197
-
198
- // Navigation from Order page back to Cart
199
- document.getElementById("back-to-cart-btn").addEventListener("click", () => {
200
- orderPage.style.display = "none";
201
- cartPage.style.display = "block";
202
- displayCartItems();
203
- });
204
-
205
- // Function to populate menu items based on category
206
- function displayMenuItems(category) {
207
- const menuContainer = category === 'Main Course' ? document.getElementById('main-course-items') : document.getElementById('appetizer-items');
208
- menuContainer.innerHTML = '';
209
- if (menuData[category]) {
210
- menuData[category].forEach(item => {
211
- const itemElement = document.createElement('div');
212
- itemElement.classList.add('menu-item');
213
- itemElement.innerHTML = `
214
- <div class="details">
215
- <h3>${item.name}</h3>
216
- <p class="price">Price: ₹${item.price}</p>
217
- </div>
218
- <button class="order-btn" onclick="addToCart('${item.name}', 1)">Order</button>
219
- `;
220
- menuContainer.appendChild(itemElement);
221
- });
222
- }
223
- }
224
-
225
- // Function to add an item to the cart
226
- function addToCart(itemName, quantity) {
227
- const item = findItem(itemName);
228
- if (item) {
229
- // Check if item already exists in the cart and update quantity
230
- const cartItem = cart.find(ci => ci.name.toLowerCase() === itemName.toLowerCase());
231
- if (cartItem) {
232
- cartItem.quantity += quantity;
233
- } else {
234
- cart.push({ name: item.name, price: item.price, quantity: quantity });
235
- }
236
- alert(item.name + " added to cart!");
237
- }
238
- }
239
-
240
- // Function to find item in the menu (checks both categories)
241
- function findItem(itemName) {
242
- let item = menuData['Main Course'].find(item => item.name.toLowerCase() === itemName.toLowerCase());
243
- if (!item) {
244
- item = menuData['Appetizers'].find(item => item.name.toLowerCase() === itemName.toLowerCase());
245
- }
246
- return item;
247
- }
248
-
249
- // Function to display cart items
250
- function displayCartItems() {
251
- const cartItemsContainer = document.getElementById('cart-items');
252
- cartItemsContainer.innerHTML = '';
253
- let total = 0;
254
- if (cart.length === 0) {
255
- cartItemsContainer.innerHTML = "<p>Your cart is empty.</p>";
256
- } else {
257
- cart.forEach(item => {
258
- const itemDiv = document.createElement('div');
259
- itemDiv.classList.add('menu-item');
260
- itemDiv.innerHTML = `
261
- <div class="details">
262
- <h3>${item.name}</h3>
263
- <p>Price: ₹${item.price} x ${item.quantity}</p>
264
- </div>
265
- `;
266
- cartItemsContainer.appendChild(itemDiv);
267
- total += item.price * item.quantity;
268
- });
269
- }
270
- document.getElementById('cart-total').innerText = "Total: ₹" + total;
271
- }
272
-
273
- // Handle Order Form Submission and Salesforce integration
274
- document.getElementById("order-form").addEventListener("submit", function(e) {
275
- e.preventDefault();
276
-
277
- // Collecting the form data
278
- const customerName = document.getElementById("customer-name").value;
279
- const customerEmail = document.getElementById("customer-email").value;
280
- const customerPhone = document.getElementById("customer-phone").value;
281
- const customerAddress = document.getElementById("customer-address").value;
282
-
283
- // Calculate total amount
284
- let total = 0;
285
- cart.forEach(item => {
286
- total += item.price * item.quantity;
287
- });
288
-
289
- // Prepare the order details
290
- const orderDetails = {
291
- customerName,
292
- customerEmail,
293
- customerPhone,
294
- customerAddress,
295
- items: cart,
296
- totalAmount: total
297
- };
298
 
299
- // Example Salesforce integration
300
- // Replace the URL below with your actual Salesforce endpoint and configure authentication as needed.
301
- fetch('https://your-salesforce-endpoint.com/api/orders', {
302
- method: 'POST',
303
- headers: {
304
- 'Content-Type': 'application/json',
305
- 'Authorization': 'Bearer YOUR_OAUTH_TOKEN' // Replace with actual OAuth token
306
- },
307
- body: JSON.stringify(orderDetails)
308
- })
309
- .then(response => response.json())
310
- .then(data => {
311
- alert("Order placed successfully! Order ID: " + data.orderId);
312
- // Clear the cart after successful order placement
313
- cart = [];
314
- // Navigate back to the category selection page
315
- orderPage.style.display = "none";
316
- categoryPage.style.display = "block";
317
- })
318
- .catch(error => {
319
- console.error("Error placing order:", error);
320
- alert("There was an error placing your order. Please try again.");
321
- });
322
- });
323
  </script>
324
 
325
  </body>
 
67
  border-radius: 4px;
68
  border: 1px solid #ccc;
69
  }
70
+
71
+ /* Salesforce OAuth Setup Styling */
72
+ .oauth-setup {
73
+ background-color: #e7f5ff;
74
+ padding: 20px;
75
+ border-radius: 8px;
76
+ margin-top: 30px;
77
+ border: 1px solid #d1e0e8;
78
+ }
79
+
80
+ .oauth-setup h2 {
81
+ color: #0070d2;
82
+ font-size: 1.8rem;
83
+ text-align: center;
84
+ }
85
+
86
+ .oauth-setup ol {
87
+ font-size: 1.1rem;
88
+ padding-left: 20px;
89
+ }
90
+
91
+ .oauth-setup li {
92
+ margin-bottom: 10px;
93
+ }
94
+
95
+ .oauth-setup pre {
96
+ background-color: #f1f1f1;
97
+ padding: 15px;
98
+ border-radius: 5px;
99
+ margin-top: 10px;
100
+ }
101
+
102
+ .oauth-setup code {
103
+ font-size: 1rem;
104
+ font-family: monospace;
105
+ }
106
  </style>
107
  </head>
108
  <body>
 
161
  <button id="back-to-cart-btn" class="order-btn">Back to Cart</button>
162
  </div>
163
 
164
+ <!-- Salesforce OAuth Setup Section -->
165
+ <div class="oauth-setup">
166
+ <h2>Salesforce OAuth Setup for API Integration</h2>
167
+ <p>Follow these steps to create a Salesforce Connected App for API integration:</p>
168
+ <ol>
169
+ <li>Go to Salesforce Setup by clicking on the gear icon in the top right corner.</li>
170
+ <li>In the quick find box, type <strong>App Manager</strong> and click on it.</li>
171
+ <li>Click on <strong>New Connected App</strong> (this is where you set up OAuth).</li>
172
+ <li>Fill out the Connected App details:</li>
173
+ <ul>
174
+ <li><strong>App Name:</strong> "BiryaniHub API Integration"</li>
175
+ <li><strong>API Name:</strong> Automatically filled.</li>
176
+ <li><strong>Contact Email:</strong> Your email.</li>
177
+ </ul>
178
+ <li>Under <strong>API (Enable OAuth Settings)</strong>, check <strong>Enable OAuth Settings</strong> and provide the following:</li>
179
+ <ul>
180
+ <li><strong>Callback URL:</strong> <code>https://login.salesforce.com</code></li>
181
+ <li><strong>Selected OAuth Scopes:</strong> Choose <code>Full Access (full)</code> or <code>API (api)</code>.</li>
182
+ </ul>
183
+ <li>Click <strong>Save</strong> to create the Connected App.</li>
184
+ </ol>
185
+
186
+ <pre><code>Consumer Key: 3MVG9WVXk15qiz1JbtW1tT9a7Wnkos2RuGamw6p1lC5uPescT5NB2nPygpo6rQ87K1T.zBEn.wR.A6JdgHnIU</code></pre>
187
+ <pre><code>Consumer Secret: A75C6B7801D5D20BED0E46631CF58C4F7FF28E4DAF442FE667553D29C35C0451</code></pre>
188
+
189
+ <div>
190
+ <button class="order-btn">Go to Salesforce Setup</button>
191
+ </div>
192
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
 
194
+ <script>
195
+ // JavaScript code for menu functionality, order submission, etc.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
  </script>
197
 
198
  </body>