dschandra commited on
Commit
4d44977
·
verified ·
1 Parent(s): affe122

Update templates/menu.html

Browse files
Files changed (1) hide show
  1. templates/menu.html +264 -589
templates/menu.html CHANGED
@@ -7,498 +7,329 @@
7
  <!-- Bootstrap CSS -->
8
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
9
  <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">
10
- <style>
11
- body {
12
- font-family: Arial, sans-serif;
13
- background-color: #fdf4e3; /* Updated background color */
14
- margin: 0;
15
- padding: 0;
16
- display: flex;
17
- flex-direction: column;
18
- }
19
- .container {
20
- max-width: 900px;
21
- }
22
- .menu-card {
23
- max-width: 350px;
24
- border-radius: 15px;
25
- overflow: hidden;
26
- background-color: #fff;
27
- margin: auto;
28
- }
29
- .menu-image {
30
- height: 200px; /* Fix height for consistency */
31
- width: 100%; /* Make sure the width spans the entire card */
32
- object-fit: cover; /* Ensures the image covers the box without distortion */
33
- border-radius: 15px 15px 0 0; /* Keeps the rounded corners at the top */
34
- }
35
- }
36
- .card-title {
37
- font-size: 1.2rem;
38
- font-weight: bold;
39
- }
40
- .card-text {
41
- font-size: 1rem;
42
- color: #6c757d;
43
- }
44
- .btn-primary {
45
- font-size: 14px;
46
- font-weight: bold;
47
- border-radius: 5px;
48
- width: 100px;
49
- background-color: #0FAA39; /* Updated button background color */
50
- border-color: #28a745;
51
-
52
- }
53
- .btn-primary:hover {
54
- background-color: #0FAA39;
55
- border-color: #ffffff;
56
- }
57
- .btn-primary:active,
58
- .btn-primary:focus {
59
- background-color: #4a5d68;
60
- border-color: #ffffff;
61
- box-shadow: none;
62
- }
63
- .view-cart-container {
64
- position: fixed;
65
- bottom: 20px;
66
- right: 20px;
67
- z-index: 999;
68
- }
69
- .view-cart-button {
70
- background-color: #0FAA39; /* Updated View Cart button background color */
71
- color: #fff;
72
- padding: 10px 20px;
73
- border-radius: 30px;
74
- font-size: 1rem;
75
- font-weight: bold;
76
- text-decoration: none;
77
- box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
78
- display: flex;
79
- align-items: center;
80
- justify-content: center;
81
- }
82
- .view-cart-button:hover {
83
- background-color: #109835; /* Slightly darker shade for hover effect */
84
- text-decoration: none;
85
- }
86
- .avatar-dropdown-container {
87
- position: relative;
88
- }
89
- .avatar-icon {
90
- width: 40px;
91
- height: 40px;
92
- border-radius: 50%;
93
- background-color: #5bbfc1;
94
- cursor: pointer;
95
- display: flex;
96
- align-items: center;
97
- justify-content: center;
98
- color: white;
99
- font-size: 20px;
100
- font-weight: bold;
101
- }
102
- .dropdown-menu {
103
- position: absolute;
104
- right: 0;
105
- top: 100%;
106
- background-color: #fff;
107
- border-radius: 5px;
108
- width: 200px; /* Adjust width as needed */
109
- box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
110
- display: none;
111
- }
112
- .avatar-dropdown-container:hover .dropdown-menu {
113
- display: block;
114
- }
115
- .dropdown-menu .dropdown-item {
116
- padding: 10px 15px;
117
- text-decoration: none;
118
- color: #333;
119
- border-bottom: 1px solid #ddd;
120
- display: block; /* Make each item stack vertically */
121
- }
122
- .dropdown-menu .dropdown-item:last-child {
123
- border-bottom: none; /* Remove the bottom border from the last item */
124
- }
125
- .dropdown-menu .dropdown-item:hover {
126
- background-color: #f1f1f1;
127
- }
128
- .fixed-search-container {
129
- position: absolute;
130
- top: 90px; /* Move it slightly lower */
131
- left: 50%;
132
- transform: translateX(-50%);
133
- width: 80%;
134
- max-width: 600px;
135
- z-index: 999; /* Keep it above content */
136
- background-color: white;
137
- padding: 10px;
138
- border-radius: 25px;
139
- box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
140
- }
141
- /* Ensure the category filter dropdown does not overlap */
142
- form.text-center.mb-4 {
143
- margin-top: 120px !important; /* Increase spacing below search bar */
144
- }
145
- /* Ensure the container has enough margin so nothing is overlapped */
146
- .container {
147
- margin-top: 180px; /* Adjust spacing based on navbar and search bar */
148
- }
149
- .fixed-top-bar {
150
- position: fixed;
151
- top: 0;
152
- left: 0;
153
- width: 100%;
154
- height: 54px; /* Adjust the height as needed */
155
- z-index: 1000;
156
- background-color: #FF6B35;
157
- color: white;
158
- padding: 15px;
159
- display: flex;
160
- justify-content: space-between;
161
- align-items: center; /* Vertically align items */
162
- z-index: 10000; /* Make sure it's at the top */
163
- }
164
-
165
- .avatar-dropdown-container {
166
- position: absolute;
167
- right: 20px; /* Adjust the value as needed to position it properly */
168
- top: 50%; /* Adjust top to place it within the header */
169
- transform: translateY(-50%); /* Correct the alignment to be perfectly centered */
170
- display: flex;
171
- align-items: center;
172
- justify-content: center;
173
- }
174
-
175
- .search-bar-container {
176
- position: absolute;
177
- left: 20px;
178
- top: 50%;
179
- transform: translateY(-50%);
180
- display: flex;
181
- justify-content: flex-start;
182
- align-items: center;
183
- width: 300px; /* Adjust width as needed */
184
- }
185
-
186
- .search-bar-container input {
187
- width: 100%;
188
- padding: 8px 10px 8px 30px; /* Add padding for the icon */
189
- font-size: 16px;
190
- border-radius: 20px;
191
- border: none;
192
- }
193
-
194
- .search-icon {
195
- position: absolute;
196
- left: 10px; /* Position the icon inside the input box */
197
- font-size: 20px;
198
- color: #888; /* Icon color */
199
- }
200
-
201
- /* Style for customization sections */
202
- .addon-section {
203
- background-color: #f8f9fa; /* Light gray background */
204
- border: 2px solid #ff6b35; /* Border color */
205
- border-radius: 8px;
206
- padding: 12px;
207
- margin-bottom: 15px; /* Spacing between sections */
208
- }
209
- /* Customization section title */
210
- .addon-section h6 {
211
- margin-bottom: 10px;
212
- font-size: 1.1rem;
213
- font-weight: bold;
214
- color: #333;
215
- }
216
- /* Style for add-on checkboxes */
217
- .addon-section .form-check {
218
- margin-left: 10px;
219
- }
220
-
221
- /* Category Filter with Custom Radio Buttons */
222
- form.text-center.mb-4 {
223
- display: flex;
224
- flex-direction: column;
225
- align-items: center;
226
- }
227
-
228
- .form-check {
229
- display: inline-block;
230
- margin-right: 15px;
231
- margin-bottom: 15px; /* Add space between buttons */
232
- }
233
-
234
- .form-check-inline {
235
- display: inline-block;
236
- margin-right: 10px; /* Space between radio buttons */
237
- }
238
-
239
- .form-check-label {
240
- font-size: 16px;
241
- margin-left: 8px; /* Space between radio button and label */
242
- }
243
-
244
- .custom-radio {
245
- appearance: none;
246
- -webkit-appearance: none;
247
- -moz-appearance: none;
248
- width: 20px; /* Size of the radio button */
249
- height: 20px; /* Size of the radio button */
250
- border: 3px solid #4CAF50; /* Green border */
251
- border-radius: 50%; /* Round shape */
252
- margin-right: 10px; /* Space between button and label */
253
- outline: none;
254
- cursor: pointer;
255
- position: relative;
256
- display: inline-block;
257
- }
258
-
259
- .custom-radio:checked {
260
- background-color: #4CAF50; /* Green color when checked */
261
- border-color: #4CAF50; /* Matching border color */
262
- }
263
-
264
- .custom-radio:checked::after {
265
- content: '';
266
- position: absolute;
267
- top: 5px; /* Adjust position for better alignment */
268
- left: 5px; /* Adjust position for better alignment */
269
- /* width: 10px; /* Increase inner dot size */
270
- /* height: 10px; /* Increase inner dot size */
271
- /* background-color: #fff; /* White dot when checked */
272
- border-radius: 50%;
273
- }
274
-
275
- .custom-radio:hover {
276
- border-color: #388E3C; /* Darker green on hover */
277
- }
278
- /* Optional: Style the labels */
279
- .form-check-label {
280
- font-size: 16px;
281
- margin-left: 8px; /* Space between radio button and label */
282
- }
283
- #decrease-quantity, #increase-quantity {
284
- width: 30px;
285
- height: 30px;
286
- font-size: 18px;
287
- }
288
-
289
- #add-to-cart {
290
- font-size: 18px;
291
- padding: 15px;
292
- background-color: #4CAF50;
293
- color: white;
294
- font-weight: bold;
295
- border-radius: 5px;
296
- border: none;
297
- }
298
-
299
- #add-to-cart:hover {
300
- background-color: #45a049; /* Slightly darker green on hover */
301
- }
302
-
303
- </style>
304
  </head>
305
  <body>
306
-
307
- <div class="fixed-top-bar">
308
- <!-- Avatar and Dropdown -->
309
- <div class="avatar-dropdown-container">
310
- <div class="avatar-icon">
311
- <span>{{ first_letter }}</span> <!-- Display the first letter of the customer's name -->
 
 
 
 
 
312
  </div>
313
- <div class="dropdown-menu">
314
- <a href="{{ url_for('customer_details') }}" class="dropdown-item">View Profile</a>
315
- <a href="{{ url_for('order_history') }}" class="dropdown-item">Order History</a>
316
- <a href="{{ url_for('logout') }}" class="dropdown-item">Logout</a>
 
317
  </div>
318
  </div>
319
 
320
- <!-- Search Bar Section -->
321
- <div class="search-bar-container">
322
- <input type="text" id="searchBar" class="form-control" placeholder="Search items or sections..." onkeyup="filterMenu()">
323
- <i class="bi bi-search search-icon"></i> <!-- Search icon inside the input -->
324
- </div>
325
- </div>
326
-
327
- <!-- Category Filter with Custom Radio Buttons -->
328
- <form method="get" action="/menu" class="text-center mb-4">
329
- <label class="form-label fw-bold">Select a Category:</label>
330
- <div class="form-check form-check-inline">
331
- <input type="radio" id="category-All" name="category" value="All" class="custom-radio"
332
- {% if selected_category == "All" %}checked{% endif %} onchange="this.form.submit()">
333
- <label class="form-check-label" for="category-All">All</label>
334
-
335
- <input type="radio" id="category-Veg" name="category" value="Veg" class="custom-radio"
336
- {% if selected_category == "Veg" %}checked{% endif %} onchange="this.form.submit()">
337
- <label class="form-check-label" for="category-Veg">Veg</label>
338
-
339
- <input type="radio" id="category-NonVeg" name="category" value="Non veg" class="custom-radio"
340
- {% if selected_category == "Non veg" %}checked{% endif %} onchange="this.form.submit()">
341
- <label class="form-check-label" for="category-NonVeg">Non veg</label>
342
-
343
- <input type="radio" id="category-CustomizedDish" name="category" value="Customized Dish" class="custom-radio"
344
- {% if selected_category == "Customized Dish" %}checked{% endif %} onchange="this.form.submit()">
345
- <label class="form-check-label" for="category-CustomizedDish">Customized Dish</label>
346
- </div>
347
- </form>
348
 
349
- <!-- Show menu items only when Customized Dish is not selected -->
 
 
 
 
 
 
 
 
350
  <div class="container mt-4">
351
  <h1 class="text-center">Menu</h1>
352
-
353
- <!-- Display text boxes for Customized Dish -->
354
- {% if selected_category == "Customized Dish" %}
355
- <div id="custom-dish-form" class="mt-4">
356
- <h3>Create Your Custom Dish</h3>
357
- <form method="POST" action="/generate_custom_dish">
358
- <div class="mb-3">
359
- <label for="custom-dish-name" class="form-label">Dish Name</label>
360
- <input type="text" class="form-control" id="custom-dish-name" name="name" required>
361
- </div>
362
- <div class="mb-3">
363
- <label for="custom-dish-description" class="form-label">Dish Description</label>
364
- <textarea class="form-control" id="custom-dish-description" name="description" required></textarea>
 
 
 
365
  </div>
366
- <button type="submit" class="btn btn-primary">Submit</button>
367
- </form>
368
- </div>
369
- {% else %}
370
-
371
- <!-- Menu Sections -->
372
- {% for section, items in ordered_menu.items() %}
373
- <h3>{{ section }}</h3>
374
- <div class="row">
375
- {% for item in items %}
376
- <div class="col-md-6 mb-4">
377
- <div class="card menu-card">
378
- <img src="{{ item.Image1__c }}" class="card-img-top menu-image" alt="{{ item.Name }}" onerror="this.src='/static/placeholder.jpg';">
379
- <div class="card-body">
380
- <h5 class="card-title">{{ item.Name }}</h5>
381
- <p class="card-text">${{ item.Price__c }}</p>
382
- <button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#itemModal"
383
- onclick="showItemDetails('{{ item.Name }}', '{{ item.Price__c }}', '{{ item.Image2__c }}', '{{ item.Description__c }}', '{{ item.Section__c }}','{{ selected_category }}')">
384
- Add
385
- </button>
386
  </div>
387
  </div>
388
- </div>
389
- {% endfor %}
390
- </div>
391
- {% endfor %}
392
- </div>
393
- {% endif %}
394
-
395
  </div>
396
 
397
  <!-- View Cart Button -->
398
  <div class="view-cart-container">
399
- <a href="/cart" class="view-cart-button">
400
- View Cart
401
- </a>
402
  </div>
403
 
404
- <!-- Bootstrap JS -->
405
- <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
406
-
407
- <!-- Modal for Item Details -->
408
- <div class="modal fade" id="itemModal" tabindex="-1" aria-labelledby="itemModalLabel" aria-hidden="true">
409
- <div class="modal-dialog modal-dialog-centered">
410
- <div class="modal-content">
411
- <div class="modal-header">
412
- <h5 class="modal-title" id="itemModalLabel">Item Details</h5>
413
- </div>
414
- <div class="modal-body">
415
- <!-- Item Image -->
416
- <img id="modal-img" class="img-fluid rounded mb-3 d-block mx-auto" alt="Item Image" style="max-height: 200px; object-fit: cover;">
417
- <!-- Item Name -->
418
- <h5 id="modal-name" class="fw-bold text-center"></h5>
419
- <!-- Item Price -->
420
- <p id="modal-price" class="text-muted text-center"></p>
421
-
422
- <!-- Quantity Control -->
423
- <div class="d-flex align-items-center justify-content-center mb-3">
424
- <button id="decrease-quantity" class="btn btn-light">-</button>
425
- <input type="number" id="quantity" class="form-control mx-2" value="1" min="1" readonly style="width: 60px;">
426
- <button id="increase-quantity" class="btn btn-light">+</button>
427
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
428
 
429
- <!-- Add to Cart Button -->
430
- <button id="add-to-cart" class="btn btn-success w-100">Add item ₹<span id="total-price">490</span></button>
 
 
 
431
  </div>
432
  </div>
433
  </div>
434
- </div>
435
 
436
  <!-- JavaScript -->
437
  <script>
438
- let itemPrice = 490; // Replace with dynamic item price
439
- let quantity = 1;
440
-
441
- // Update total price based on quantity
442
- function updatePrice() {
443
- const totalPrice = itemPrice * quantity;
444
- document.getElementById('total-price').innerText = totalPrice;
445
- }
446
-
447
- // Decrease quantity
448
- document.getElementById('decrease-quantity').addEventListener('click', function() {
449
- if (quantity > 1) {
450
- quantity--;
 
 
 
 
 
 
 
 
 
 
 
 
451
  document.getElementById('quantity').value = quantity;
452
  updatePrice();
453
- }
454
- });
455
-
456
- // Increase quantity
457
- document.getElementById('increase-quantity').addEventListener('click', function() {
458
- quantity++;
459
- document.getElementById('quantity').value = quantity;
460
- updatePrice();
461
- });
462
-
463
  function showItemDetails(name, price, image, description, section, selectedCategory) {
464
  document.getElementById('modal-name').innerText = name;
465
  document.getElementById('modal-price').innerText = `$${price}`;
466
  document.getElementById('modal-img').src = image || '/static/placeholder.jpg';
467
  document.getElementById('modal-description').innerText = description || 'No description available.';
468
- document.getElementById('addons-list').innerHTML = 'Loading customization options...';
469
- document.getElementById('modal-instructions').value = '';
 
470
  // Set section and category for reference
471
  const modalSectionEl = document.getElementById('modal-section');
472
  modalSectionEl.setAttribute('data-section', section);
473
  modalSectionEl.setAttribute('data-category', selectedCategory);
 
474
  // Fetch customization options based on the section
475
  fetch(`/api/addons?item_name=${encodeURIComponent(name)}&item_section=${encodeURIComponent(section)}`)
476
  .then(response => response.json())
477
  .then(data => {
478
  const addonsList = document.getElementById('addons-list');
479
  addonsList.innerHTML = ''; // Clear previous content
480
-
481
  if (!data.success || !data.addons || data.addons.length === 0) {
482
  addonsList.innerHTML = '<p>No customization options available.</p>';
483
  return;
484
  }
 
485
  // Display customization options inside styled divs
486
  data.addons.forEach(addon => {
487
  const sectionDiv = document.createElement('div');
488
- sectionDiv.classList.add('addon-section'); // Add styling class
489
- // Add section title
490
  const title = document.createElement('h6');
491
  title.innerText = addon.name;
492
  sectionDiv.appendChild(title);
493
- // Create options list
494
  const optionsContainer = document.createElement('div');
495
  addon.options.forEach((option, index) => {
496
  const optionId = `addon-${addon.name.replace(/\s+/g, '')}-${index}`;
497
  const listItem = document.createElement('div');
498
  listItem.classList.add('form-check');
499
  listItem.innerHTML = `
500
- <input type="checkbox" class="form-check-input addon-option" id="${optionId}" value="${option}"
501
- data-name="${option}" data-price="${addon.extra_charge ? addon.extra_charge_amount : 0}">
502
  <label class="form-check-label" for="${optionId}">
503
  ${option} ${addon.extra_charge ? `($${addon.extra_charge_amount})` : ''}
504
  </label>
@@ -514,162 +345,6 @@
514
  document.getElementById('addons-list').innerHTML = '<p>Error loading customization options.</p>';
515
  });
516
  }
517
-
518
- function filterMenu() {
519
- let input = document.getElementById('searchBar').value.toLowerCase(); // Get the value from search bar
520
- let sections = document.querySelectorAll('h3'); // Select section headers
521
- let items = document.querySelectorAll('.menu-card'); // Select all items
522
- let matchedSections = new Set(); // Store matched sections
523
-
524
- // Hide all items initially
525
- items.forEach(item => {
526
- let itemName = item.querySelector('.card-title').innerText.toLowerCase(); // Get item name
527
- let itemSection = item.closest('.row').previousElementSibling.innerText.toLowerCase(); // Get section name
528
-
529
- // If the search matches item name or section, show the item
530
- if (itemName.includes(input) || (itemSection && itemSection.includes(input))) {
531
- item.style.display = 'block'; // Show item if it matches search
532
- matchedSections.add(item.closest('.row')); // Add section to matched list
533
- } else {
534
- item.style.display = 'none'; // Hide item if not matched
535
- }
536
- });
537
-
538
- // Show or hide sections based on matched items
539
- sections.forEach(section => {
540
- let sectionRow = section.nextElementSibling; // The row containing items
541
- if (matchedSections.has(sectionRow)) {
542
- section.style.display = 'block'; // Show section header
543
- sectionRow.style.display = 'flex'; // Show section items
544
- } else {
545
- section.style.display = 'none'; // Hide section header
546
- sectionRow.style.display = 'none'; // Hide section items
547
- }
548
- });
549
- }
550
-
551
- function addToCartFromModal() {
552
- const itemName = document.getElementById('modal-name').innerText;
553
- let itemPrice = parseFloat(document.getElementById('modal-price').innerText.replace('$', ''));
554
-
555
- // Validate item price
556
- if (isNaN(itemPrice)) {
557
- alert('Invalid price for the item. Please check the item details.');
558
- return;
559
- }
560
-
561
- const itemImage = document.getElementById('modal-img').src;
562
- console.log(itemName, itemPrice, itemImage); // Log values for debugging
563
- const modalSectionEl = document.getElementById('modal-section');
564
- const section = modalSectionEl.getAttribute('data-section');
565
- const selectedCategory = modalSectionEl.getAttribute('data-category');
566
- if (!itemName || !itemPrice || !section) {
567
- console.error('Missing data for cart item:', { itemName, itemPrice, section });
568
- return;
569
- }
570
-
571
- // Collect selected add-ons
572
- let selectedAddOns = Array.from(
573
- document.querySelectorAll('#addons-list input[type="checkbox"]:checked')
574
- ).map(addon => ({
575
- name: addon.getAttribute('data-name') || 'Default Name', //Fallback Name
576
- price: parseFloat(addon.getAttribute('data-price') || 0)
577
- }));
578
- const instructions = document.getElementById('modal-instructions').value;
579
-
580
- // Prepare data for the cart
581
- const cartPayload = {
582
- itemName: itemName,
583
- itemPrice: itemPrice,
584
- itemImage: itemImage,
585
- section: section,
586
- category: selectedCategory,
587
- addons: selectedAddOns,
588
- instructions: instructions
589
- };
590
-
591
- // Send the cart data to the server
592
- fetch('/cart/add', {
593
- method: 'POST',
594
- headers: {
595
- 'Content-Type': 'application/json',
596
- },
597
- body: JSON.stringify(cartPayload)
598
- })
599
- .then(response => response.json())
600
- .then(data => {
601
- if (data.success) {
602
- alert('Item added to cart successfully!');
603
- updateCartUI(data.cart); // Update cart UI after adding an item
604
- const modal = document.getElementById('itemModal');
605
- const modalInstance = bootstrap.Modal.getInstance(modal);
606
- modalInstance.hide();
607
- } else {
608
- alert(data.error || 'Failed to add item to cart.');
609
- }
610
- })
611
- .catch(err => {
612
- console.error('Error adding item to cart:', err);
613
- alert('An error occurred while adding the item to the cart.');
614
- });
615
- }
616
- function updateCartUI(cart) {
617
- if (!Array.isArray(cart)) {
618
- console.error('Invalid cart data:', cart);
619
- return;
620
- }
621
- const cartIcon = document.getElementById('cart-icon');
622
- cartIcon.innerText = cart.length; // Assuming cart is an array of items
623
- }
624
-
625
- function updateCartDisplay(cart) {
626
- if (!Array.isArray(cart)) {
627
- console.error('Invalid cart data:', cart);
628
- return;
629
- }
630
- const cartCountElement = document.getElementById('cart-count');
631
- cartCountElement.innerText = cart.length; // Update cart item count
632
- // Optionally, show a small success notification that the item was added
633
- const successNotification = document.createElement('div');
634
- successNotification.classList.add('success-notification');
635
- successNotification.innerText = 'Item added to cart!';
636
- document.body.appendChild(successNotification);
637
- setTimeout(() => {
638
- successNotification.remove(); // Remove success notification after a few seconds
639
- }, 2000);
640
- }
641
-
642
- // Function to round reward points to a single digit
643
- function roundRewardPoints() {
644
- // Get the reward points element
645
- let rewardPointsElement = document.getElementById('reward-points');
646
-
647
- // Check if the element exists in the DOM
648
- if (rewardPointsElement) {
649
- let rewardPointsText = rewardPointsElement.innerText.trim(); // Get and trim the value to remove any extra spaces
650
-
651
- // Check if the innerText is a valid number
652
- let rewardPoints = parseFloat(rewardPointsText);
653
-
654
- // If it's a valid number, round it to 1 decimal place
655
- if (!isNaN(rewardPoints)) {
656
- rewardPointsElement.innerText = rewardPoints.toFixed(1); // Round to 1 decimal place
657
- } else {
658
- console.error("Reward points value is not a valid number:", rewardPointsText);
659
- }
660
- } else {
661
- console.error("Reward points element is missing.");
662
- }
663
- }
664
- // Run the function when the page loads
665
- window.onload = roundRewardPoints;
666
-
667
  </script>
668
-
669
- <!-- Bootstrap JS -->
670
- <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
671
  </body>
672
  </html>
673
- </script>
674
- </body>
675
- </html>
 
7
  <!-- Bootstrap CSS -->
8
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
9
  <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">
10
+ <style>
11
+ body {
12
+ font-family: Arial, sans-serif;
13
+ background-color: #fdf4e3;
14
+ margin: 0;
15
+ padding: 0;
16
+ display: flex;
17
+ flex-direction: column;
18
+ }
19
+
20
+ .container {
21
+ max-width: 900px;
22
+ }
23
+
24
+ .menu-card {
25
+ max-width: 350px;
26
+ border-radius: 15px;
27
+ overflow: hidden;
28
+ background-color: #fff;
29
+ margin: auto;
30
+ }
31
+
32
+ .menu-image {
33
+ height: 200px;
34
+ width: 100%;
35
+ object-fit: cover;
36
+ border-radius: 15px 15px 0 0;
37
+ }
38
+
39
+ .card-title {
40
+ font-size: 1.2rem;
41
+ font-weight: bold;
42
+ }
43
+
44
+ .card-text {
45
+ font-size: 1rem;
46
+ color: #6c757d;
47
+ }
48
+
49
+ .btn-primary {
50
+ font-size: 14px;
51
+ font-weight: bold;
52
+ border-radius: 5px;
53
+ width: 100px;
54
+ background-color: #0FAA39;
55
+ border-color: #28a745;
56
+ }
57
+
58
+ .btn-primary:hover {
59
+ background-color: #0FAA39;
60
+ border-color: #ffffff;
61
+ }
62
+
63
+ .btn-primary:active,
64
+ .btn-primary:focus {
65
+ background-color: #4a5d68;
66
+ border-color: #ffffff;
67
+ box-shadow: none;
68
+ }
69
+
70
+ .view-cart-container {
71
+ position: fixed;
72
+ bottom: 20px;
73
+ right: 20px;
74
+ z-index: 999;
75
+ }
76
+
77
+ .view-cart-button {
78
+ background-color: #0FAA39;
79
+ color: #fff;
80
+ padding: 10px 20px;
81
+ border-radius: 30px;
82
+ font-size: 1rem;
83
+ font-weight: bold;
84
+ text-decoration: none;
85
+ box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
86
+ display: flex;
87
+ align-items: center;
88
+ justify-content: center;
89
+ }
90
+
91
+ .view-cart-button:hover {
92
+ background-color: #109835;
93
+ text-decoration: none;
94
+ }
95
+
96
+ /* Modal and customization sections */
97
+ .addon-section {
98
+ background-color: #f8f9fa;
99
+ border: 2px solid #ff6b35;
100
+ border-radius: 8px;
101
+ padding: 12px;
102
+ margin-bottom: 15px;
103
+ }
104
+
105
+ .addon-section h6 {
106
+ margin-bottom: 10px;
107
+ font-size: 1.1rem;
108
+ font-weight: bold;
109
+ color: #333;
110
+ }
111
+
112
+ .addon-section .form-check {
113
+ margin-left: 10px;
114
+ }
115
+
116
+ /* Quantity Control */
117
+ #decrease-quantity, #increase-quantity {
118
+ width: 30px;
119
+ height: 30px;
120
+ font-size: 18px;
121
+ }
122
+
123
+ #add-to-cart {
124
+ font-size: 18px;
125
+ padding: 15px;
126
+ background-color: #4CAF50;
127
+ color: white;
128
+ font-weight: bold;
129
+ border-radius: 5px;
130
+ border: none;
131
+ }
132
+
133
+ #add-to-cart:hover {
134
+ background-color: #45a049;
135
+ }
136
+
137
+ .form-check-label {
138
+ font-size: 16px;
139
+ margin-left: 8px;
140
+ }
141
+ </style>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  </head>
143
  <body>
144
+ <div class="fixed-top-bar">
145
+ <!-- Avatar and Dropdown -->
146
+ <div class="avatar-dropdown-container">
147
+ <div class="avatar-icon">
148
+ <span>{{ first_letter }}</span>
149
+ </div>
150
+ <div class="dropdown-menu">
151
+ <a href="{{ url_for('customer_details') }}" class="dropdown-item">View Profile</a>
152
+ <a href="{{ url_for('order_history') }}" class="dropdown-item">Order History</a>
153
+ <a href="{{ url_for('logout') }}" class="dropdown-item">Logout</a>
154
+ </div>
155
  </div>
156
+
157
+ <!-- Search Bar Section -->
158
+ <div class="search-bar-container">
159
+ <input type="text" id="searchBar" class="form-control" placeholder="Search items or sections..." onkeyup="filterMenu()">
160
+ <i class="bi bi-search search-icon"></i>
161
  </div>
162
  </div>
163
 
164
+ <!-- Category Filter -->
165
+ <form method="get" action="/menu" class="text-center mb-4">
166
+ <label class="form-label fw-bold">Select a Category:</label>
167
+ <div class="form-check form-check-inline">
168
+ <input type="radio" id="category-All" name="category" value="All" class="custom-radio" {% if selected_category == "All" %}checked{% endif %} onchange="this.form.submit()">
169
+ <label class="form-check-label" for="category-All">All</label>
170
+
171
+ <input type="radio" id="category-Veg" name="category" value="Veg" class="custom-radio" {% if selected_category == "Veg" %}checked{% endif %} onchange="this.form.submit()">
172
+ <label class="form-check-label" for="category-Veg">Veg</label>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
 
174
+ <input type="radio" id="category-NonVeg" name="category" value="Non veg" class="custom-radio" {% if selected_category == "Non veg" %}checked{% endif %} onchange="this.form.submit()">
175
+ <label class="form-check-label" for="category-NonVeg">Non veg</label>
176
+
177
+ <input type="radio" id="category-CustomizedDish" name="category" value="Customized Dish" class="custom-radio" {% if selected_category == "Customized Dish" %}checked{% endif %} onchange="this.form.submit()">
178
+ <label class="form-check-label" for="category-CustomizedDish">Customized Dish</label>
179
+ </div>
180
+ </form>
181
+
182
+ <!-- Menu Section -->
183
  <div class="container mt-4">
184
  <h1 class="text-center">Menu</h1>
185
+
186
+ <!-- Display text boxes for Customized Dish -->
187
+ {% if selected_category == "Customized Dish" %}
188
+ <div id="custom-dish-form" class="mt-4">
189
+ <h3>Create Your Custom Dish</h3>
190
+ <form method="POST" action="/generate_custom_dish">
191
+ <div class="mb-3">
192
+ <label for="custom-dish-name" class="form-label">Dish Name</label>
193
+ <input type="text" class="form-control" id="custom-dish-name" name="name" required>
194
+ </div>
195
+ <div class="mb-3">
196
+ <label for="custom-dish-description" class="form-label">Dish Description</label>
197
+ <textarea class="form-control" id="custom-dish-description" name="description" required></textarea>
198
+ </div>
199
+ <button type="submit" class="btn btn-primary">Submit</button>
200
+ </form>
201
  </div>
202
+ {% else %}
203
+ <!-- Display Menu Items -->
204
+ {% for section, items in ordered_menu.items() %}
205
+ <h3>{{ section }}</h3>
206
+ <div class="row">
207
+ {% for item in items %}
208
+ <div class="col-md-6 mb-4">
209
+ <div class="card menu-card">
210
+ <img src="{{ item.Image1__c }}" class="card-img-top menu-image" alt="{{ item.Name }}" onerror="this.src='/static/placeholder.jpg';">
211
+ <div class="card-body">
212
+ <h5 class="card-title">{{ item.Name }}</h5>
213
+ <p class="card-text">${{ item.Price__c }}</p>
214
+ <button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#itemModal"
215
+ onclick="showItemDetails('{{ item.Name }}', {{ item.Price__c }}, '{{ item.Image2__c }}', '{{ item.Description__c }}', '{{ item.Section__c }}', '{{ selected_category }}')">
216
+ Add
217
+ </button>
218
+ </div>
 
 
 
219
  </div>
220
  </div>
221
+ {% endfor %}
222
+ </div>
223
+ {% endfor %}
224
+ {% endif %}
 
 
 
225
  </div>
226
 
227
  <!-- View Cart Button -->
228
  <div class="view-cart-container">
229
+ <a href="/cart" class="view-cart-button">View Cart</a>
 
 
230
  </div>
231
 
232
+ <!-- Modal for Item Details -->
233
+ <div class="modal fade" id="itemModal" tabindex="-1" aria-labelledby="itemModalLabel" aria-hidden="true">
234
+ <div class="modal-dialog modal-dialog-centered">
235
+ <div class="modal-content">
236
+ <div class="modal-header">
237
+ <h5 class="modal-title" id="itemModalLabel">Item Details</h5>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
  </div>
239
+ <div class="modal-body">
240
+ <!-- Item Image -->
241
+ <img id="modal-img" class="img-fluid rounded mb-3 d-block mx-auto" alt="Item Image" style="max-height: 200px; object-fit: cover;">
242
+ <!-- Item Name -->
243
+ <h5 id="modal-name" class="fw-bold text-center"></h5>
244
+ <!-- Item Price -->
245
+ <p id="modal-price" class="text-muted text-center"></p>
246
+
247
+ <!-- Quantity Control -->
248
+ <div class="d-flex align-items-center justify-content-center mb-3">
249
+ <button id="decrease-quantity" class="btn btn-light">-</button>
250
+ <input type="number" id="quantity" class="form-control mx-2" value="1" min="1" readonly style="width: 60px;">
251
+ <button id="increase-quantity" class="btn btn-light">+</button>
252
+ </div>
253
 
254
+ <!-- Add to Cart Button -->
255
+ <button id="add-to-cart" class="btn btn-success w-100">Add item ₹<span id="total-price">490</span></button>
256
+ <!-- Customization Addons -->
257
+ <div id="addons-list" class="addons-container">Loading customization options...</div>
258
+ </div>
259
  </div>
260
  </div>
261
  </div>
 
262
 
263
  <!-- JavaScript -->
264
  <script>
265
+ let itemPrice = 490; // Static price from the item details
266
+ let quantity = 1;
267
+
268
+ // Update total price based on quantity and customization options
269
+ function updatePrice() {
270
+ let totalPrice = itemPrice * quantity;
271
+ const selectedAddOns = document.querySelectorAll('.addon-option:checked');
272
+ selectedAddOns.forEach(addon => {
273
+ totalPrice += parseFloat(addon.getAttribute('data-price') || 0); // Add addon prices
274
+ });
275
+ document.getElementById('total-price').innerText = totalPrice;
276
+ }
277
+
278
+ // Decrease quantity
279
+ document.getElementById('decrease-quantity').addEventListener('click', function() {
280
+ if (quantity > 1) {
281
+ quantity--;
282
+ document.getElementById('quantity').value = quantity;
283
+ updatePrice();
284
+ }
285
+ });
286
+
287
+ // Increase quantity
288
+ document.getElementById('increase-quantity').addEventListener('click', function() {
289
+ quantity++;
290
  document.getElementById('quantity').value = quantity;
291
  updatePrice();
292
+ });
293
+
 
 
 
 
 
 
 
 
294
  function showItemDetails(name, price, image, description, section, selectedCategory) {
295
  document.getElementById('modal-name').innerText = name;
296
  document.getElementById('modal-price').innerText = `$${price}`;
297
  document.getElementById('modal-img').src = image || '/static/placeholder.jpg';
298
  document.getElementById('modal-description').innerText = description || 'No description available.';
299
+ itemPrice = price; // Static price remains as selected price
300
+ updatePrice(); // Update the price based on quantity and customization
301
+
302
  // Set section and category for reference
303
  const modalSectionEl = document.getElementById('modal-section');
304
  modalSectionEl.setAttribute('data-section', section);
305
  modalSectionEl.setAttribute('data-category', selectedCategory);
306
+
307
  // Fetch customization options based on the section
308
  fetch(`/api/addons?item_name=${encodeURIComponent(name)}&item_section=${encodeURIComponent(section)}`)
309
  .then(response => response.json())
310
  .then(data => {
311
  const addonsList = document.getElementById('addons-list');
312
  addonsList.innerHTML = ''; // Clear previous content
313
+
314
  if (!data.success || !data.addons || data.addons.length === 0) {
315
  addonsList.innerHTML = '<p>No customization options available.</p>';
316
  return;
317
  }
318
+
319
  // Display customization options inside styled divs
320
  data.addons.forEach(addon => {
321
  const sectionDiv = document.createElement('div');
322
+ sectionDiv.classList.add('addon-section');
 
323
  const title = document.createElement('h6');
324
  title.innerText = addon.name;
325
  sectionDiv.appendChild(title);
 
326
  const optionsContainer = document.createElement('div');
327
  addon.options.forEach((option, index) => {
328
  const optionId = `addon-${addon.name.replace(/\s+/g, '')}-${index}`;
329
  const listItem = document.createElement('div');
330
  listItem.classList.add('form-check');
331
  listItem.innerHTML = `
332
+ <input type="checkbox" class="form-check-input addon-option" id="${optionId}" value="${option}" data-name="${option}" data-price="${addon.extra_charge ? addon.extra_charge_amount : 0}">
 
333
  <label class="form-check-label" for="${optionId}">
334
  ${option} ${addon.extra_charge ? `($${addon.extra_charge_amount})` : ''}
335
  </label>
 
345
  document.getElementById('addons-list').innerHTML = '<p>Error loading customization options.</p>';
346
  });
347
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
348
  </script>
 
 
 
349
  </body>
350
  </html>