Swathi6 commited on
Commit
402ab6e
·
verified ·
1 Parent(s): 075312b

Update templates/menu.html

Browse files
Files changed (1) hide show
  1. templates/menu.html +252 -768
templates/menu.html CHANGED
@@ -3,792 +3,276 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Menu</title>
7
- <!-- Bootstrap CSS -->
8
- <link href="https://cdn.jsdelivr.net/npm/[email protected]/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
- display: flex;
29
- flex-direction: column;
30
- }
31
- .menu-image {
32
- height: 200px; /* Fixed height */
33
- width: 100%; /* Full width of the card */
34
- object-fit: fill; /* Ensure the image covers the area and maintains the aspect ratio */
35
- border-radius: 15px 15px 0 0; /* Rounded top corners */
36
- }
37
- .card-title {
38
- font-size: 1.2rem;
39
- font-weight: bold;
40
- margin: 10px 0;
41
- }
42
- .card-text {
43
- font-size: 1rem;
44
- color: #6c757d;
45
- }
46
- .btn-primary {
47
- font-size: 13px;
48
- font-weight: bold;
49
- border-radius: 5px;
50
- width: 100px;
51
- background-color: #0FAA39; /* Updated button background color */
52
- border-color: #0FAA39;
53
- }
54
- .btn-primary:hover {
55
- background-color: #0FAA39;
56
- border-color: #0FAA39;
57
- }
58
- .btn-primary:active,
59
- .btn-primary:focus {
60
- background-color: #0FAA39;
61
- border-color: #ffffff;
62
- box-shadow: none;
63
- }
64
- .view-cart-container {
65
- text-align: center;
66
- margin-top: 20px;
67
- }
68
- .view-cart-button {
69
- display: inline-flex;
70
- align-items: center;
71
- justify-content: center;
72
- background-color: #007BFF; /* Blue color */
73
- color: white;
74
- padding: 10px 20px;
75
- border-radius: 50px; /* Rounded corners */
76
- font-size: 16px;
77
- font-weight: bold;
78
- text-decoration: none;
79
- box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1); /* Shadow effect */
80
- transition: background-color 0.3s ease;
81
- }
82
- .view-cart-button:hover {
83
- background-color: #0056b3; /* Darker blue on hover */
84
- }
85
- .cart-icon {
86
- margin-right: 10px; /* Space between icon and text */
87
- font-size: 20px; /* Icon size */
88
- }
89
- .avatar-dropdown-container {
90
- position: relative;
91
- }
92
- .avatar-icon {
93
- width: 40px;
94
- height: 40px;
95
- border-radius: 50%;
96
- background-color: #5bbfc1;
97
- cursor: pointer;
98
- display: flex;
99
- align-items: center;
100
- justify-content: center;
101
- color: white;
102
- font-size: 20px;
103
- font-weight: bold;
104
- }
105
- .dropdown-menu {
106
- position: absolute;
107
- right: 0;
108
- top: 100%;
109
- background-color: #fff;
110
- border-radius: 5px;
111
- width: 200px; /* Adjust width as needed */
112
- box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
113
- display: none;
114
- }
115
- .avatar-dropdown-container:hover .dropdown-menu {
116
- display: block;
117
- }
118
- .avatar-dropdown-container {
119
- position: absolute;
120
- right: 20px; /* Adjust the value as needed to position it properly */
121
- top: 50%; /* Adjust top to place it within the header */
122
- transform: translateY(-50%); /* Correct the alignment to be perfectly centered */
123
- display: flex;
124
- align-items: right;
125
- justify-content: center;
126
- }
127
-
128
- .dropdown-menu .dropdown-item {
129
- padding: 10px 15px;
130
- text-decoration: none;
131
- color: #333;
132
- border-bottom: 1px solid #ddd;
133
- display: block; /* Make each item stack vertically */
134
- }
135
- .dropdown-menu .dropdown-item:last-child {
136
- border-bottom: none; /* Remove the bottom border from the last item */
137
- }
138
- .dropdown-menu .dropdown-item:hover {
139
- background-color: #f1f1f1;
140
- }
141
- .fixed-search-container {
142
- position: absolute;
143
- top: 90px; /* Move it slightly lower */
144
- left: 50%;
145
- transform: translateX(-50%);
146
- width: 80%;
147
- max-width: 600px;
148
- z-index: 999; /* Keep it above content */
149
- background-color: white;
150
- padding: 10px;
151
- border-radius: 25px;
152
- box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
153
- }
154
- /* Ensure the category filter dropdown does not overlap */
155
- form.text-center.mb-4 {
156
- margin-top: 10px; /* No margin at the top */
157
- margin-bottom: 0px; /* Small space at the bottom */
158
- }
159
- /* Ensure the container has enough margin so nothing is overlapped */
160
- .container {
161
- margin-top: 10px; /* Adjust spacing based on navbar and search bar */
162
- padding-top: 0 !important; /* Ensure no padding is added by default */
163
- }
164
- h1.text-center {
165
- margin-top: 10px; /* Reduced space above */
166
- padding-top: 0 !important; /* Removed padding */
167
- font-weight: semi-bold; /* Make the "Menu" text bold */
168
- }
169
- .fixed-top-bar {
170
- /* Remove the fixed positioning */
171
- position: relative; /* Change from fixed to relative */
172
- top: 0;
173
- left: 0;
174
- width: 100%;
175
- height: 54px;
176
- background-color: #FF6B35;
177
- color: white;
178
- padding: 15px;
179
- display: flex;
180
- justify-content: space-between;
181
- align-items: center; /* Vertically align items */
182
- z-index: 1000; /* Make sure it's still above other content */
183
- }
184
- .search-bar-container {
185
- padding: 10px;
186
- position: absolute;
187
- left: 20px;
188
- top: 50%;
189
- transform: translateY(-50%);
190
- display: flex;
191
- align-items: center;
192
- width: 300px; /* Adjust width as needed */
193
- background-color: white; /* Background color for the input container */
194
- border-radius: 25px; /* Rounded corners for the input box */
195
- box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1); /* Slight shadow effect */
196
- }
197
- .search-bar-container input {
198
- width: 100%; /* Ensure input takes up full width of container */
199
- padding: 8px 10px 8px 30px; /* Padding for text and icon */
200
- font-size: 16px;
201
- border-radius: 25px; /* Rounded corners */
202
- border: 1px solid #ddd; /* Light border color */
203
- outline: none; /* Remove outline */
204
- }
205
- .search-icon {
206
- position: absolute;
207
- left: 15px; /* Position the icon inside the input box */
208
- font-size: 18px;
209
- color: #888; /* Icon color */
210
- }
211
- /* Style for customization sections */
212
- .addon-section {
213
- background-color: #fff; /* Light gray background */
214
- border: 2px solid #6c757d; /* Border color */
215
- border-radius: 8px;
216
- padding: 12px;
217
- margin-bottom: 10px; /* Spacing between sections */
218
- }
219
- /* Customization section title */
220
- .addon-section h6 {
221
- margin-bottom: 10px;
222
- font-size: 1.1rem;
223
- font-weight: bold;
224
- color: #343a40; /* Darker title text */
225
- }
226
- /* Style for add-on checkboxes */
227
- .addon-section .form-check {
228
- display: inline-flex; /* Display checkboxes horizontally */
229
- align-items: center; /* Align checkboxes and labels */
230
- margin-left: 10px; /* Space between checkboxes */
231
- color: #343a40; /* Darker text color */
232
- }
233
- /* Customize the default checkbox */
234
- .addon-section .form-check-input {
235
- -webkit-appearance: none; /* Remove default checkbox styling in Webkit browsers (e.g. Chrome, Safari) */
236
- -moz-appearance: none; /* Remove default checkbox styling in Firefox */
237
- appearance: none; /* Remove default checkbox styling in all browsers */
238
- width: 20px;
239
- height: 20px;
240
- border: 2px solid #343a40; /* Darker border color */
241
- border-radius: 5px; /* Rounded corners */
242
- background-color: #f0f0f0; /* Lighter gray background when unchecked */
243
- position: relative;
244
- margin-right: 10px; /* Add space between the checkbox and label */
245
- }
246
-
247
- /* Checked state for the custom checkbox */
248
- .addon-section .form-check-input:checked {
249
- background-color: #006400; /* Dark green background when checked */
250
- border-color: #006400; /* Dark green border when checked */
251
- }
252
- /* Add the check mark when checkbox is checked */
253
- .addon-section .form-check-input:checked::before {
254
- content: ''; /* Unicode check mark */
255
- font-size: 14px;
256
- position: absolute;
257
- top: 3px;
258
- left: 4px;
259
- color: white; /* White color for the check mark */
260
- }
261
- /* Hover effect for the checkboxes */
262
- .addon-section .form-check-input:hover {
263
- /* background-color: #006400; /* Slightly darker background on hover */
264
- }
265
- /* Focus effect on custom checkbox */
266
- .addon-section .form-check-input:focus {
267
- outline: none;
268
- box-shadow: 0 0 0 2px #006400; /* Green focus outline */
269
- }
270
- /* Custom checkbox label styles */
271
- .addon-section .form-check-label {
272
- font-size: 16px;
273
- margin-left: 5px;
274
- cursor: pointer;
275
- display: inline-block; /* Ensure label aligns correctly with checkbox */
276
- vertical-align: middle; /* Align text vertically with the checkbox */
277
- }
278
- /* Fix alignment of text and checkbox */
279
- .addon-section .form-check input[type="checkbox"],
280
- .addon-section .form-check label {
281
- display: inline-block;
282
- /* vertical-align: middle; /* Align text and checkboxes vertically */
283
- }
284
- /* Category Filter with Custom Radio Buttons */
285
- form.text-center.mb-4 {
286
- display: flex;
287
- flex-direction: column;
288
- align-items: center;
289
- justify-content: center;
290
- margin-bottom: 5px; /* Reduce bottom margin */
291
- }
292
- .form-check {
293
- display: inline-block;
294
- margin-right: 5px; /* Reduced space between radio button and label */
295
- margin-bottom: 0; /* Remove bottom margin */
296
- margin-top: 10px; /* Adds space between categories and Customized Dish */
297
- vertical-align: middle; /* Align radio buttons vertically */
298
- }
299
- .form-check-inline {
300
- display: inline-block;
301
- margin-right: 5px; /* Decrease space between each radio button */
302
- }
303
- .form-check-label {
304
- display: inline-block;
305
- font-size: 16px;
306
- margin-left: 5px; /* Spacing between radio button and label */
307
- vertical-align: middle; /* Align label vertically */
308
- }
309
- form-check-input addon-option{
310
- color: #333d47;
311
- }
312
- .custom-radio {
313
- appearance: none;
314
- -webkit-appearance: none;
315
- -moz-appearance: none;
316
- width: 20px;
317
- height: 20px;
318
- border: 3px solid #4CAF50; /* Green border */
319
- border-radius: 50%;
320
- margin-right: -5px; /* Reduced spacing between button and label */
321
- outline: none;
322
- cursor: pointer;
323
- position: relative;
324
- display: inline-block;
325
- vertical-align: middle; /* Align vertically with text */
326
- }
327
- .custom-radio:checked {
328
- background-color: #4CAF50; /* Green color when checked */
329
- border-color: #4CAF50; /* Matching border color */
330
- }
331
- .custom-radio:checked::after {
332
- content: '';
333
- position: relative;
334
- top: 5px;
335
- left: 5px;
336
- border-radius: 50%;
337
- }
338
- .custom-radio:hover {
339
- border-color: #388E3C;
340
- }
341
- /* Optional: Style the labels */
342
- .form-check-label {
343
- font-size: 16px;
344
- margin-left: 8px; /* Space between the radio button and the label */
345
- }
346
- .cart-container {
347
- display: flex;
348
- align-items: center;
349
- gap: 10px;
350
- }
351
- .modal-footer {
352
- display: flex;
353
- align-items: center;
354
- justify-content: space-between; /* Space between quantity and Add to Cart button */
355
- padding: 10px;
356
- }
357
- .modal-footer .d-flex {
358
- display: flex;
359
- align-items: center;
360
- gap: 10px; /* Space between quantity buttons */
361
- }
362
- .modal-footer .btn {
363
- height: 40px; /* Set consistent button height */
364
- padding: 0 15px; /* Adjust padding to fit inside the buttons */
365
- }
366
- .modal-footer .form-control {
367
- width: 50px; /* Fixed width for quantity input */
368
- height: 40px; /* Match the height of buttons */
369
- text-align: center; /* Center the value inside the input */
370
- }
371
- .modal-footer .btn-primary {
372
- background-color: #0FAA39; /* Green background for Add to Cart button */
373
- border-color: #0FAA39; /* Border color to match button background */
374
- font-weight: bold; /* Bold text */
375
- padding: 10px 20px; /* Adjust padding to make the button look better */
376
- height: 40px; /* Match the height with quantity buttons */
377
- display: flex;
378
- justify-content: center;
379
- align-items: center;
380
- width: auto; /* Auto width to adjust to button text */
381
- }
382
- .modal-footer .btn-outline-secondary {
383
- height: 40px; /* Ensure quantity buttons are the same size */
384
- width: 40px; /* Make sure the buttons are square */
385
- }
386
- @media (max-width: 576px) {
387
- /* Responsive adjustments for smaller screens */
388
- .modal-dialog {
389
- max-width: 98%; /* Adjust modal width for smaller screens */
390
- }
391
- .modal-footer .btn {
392
- height: 35px; /* Smaller buttons for small screens */
393
- }
394
- .modal-footer .form-control {
395
- width: 40px; /* Adjust input size for smaller screens */
396
- height: 35px;
397
- }
398
- }
399
- </style>
400
  </head>
401
  <body>
402
- <!-- Search Bar Section -->
403
- <div class="search-bar-container">
404
- <input type="text" id="searchBar" class="form-control" placeholder="Search items or sections..." onkeyup="filterMenu()">
405
- <span class="search-icon"><i class="bi bi-search"></i></span> <!-- Search icon inside the input -->
406
- </div>
407
 
408
- <!-- Bootstrap Icons CDN -->
409
- <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">
 
 
410
 
411
- <div class="fixed-top-bar">
412
- <!-- Avatar and Dropdown -->
413
- <div class="avatar-dropdown-container">
414
- <div class="avatar-icon">
415
- <span>{{ first_letter }}</span> <!-- Display the first letter of the customer's name -->
416
- </div>
417
- <div class="dropdown-menu">
418
- <a href="{{ url_for('customer_details') }}" class="dropdown-item">View Profile</a>
419
- <a href="{{ url_for('order_history') }}" class="dropdown-item">Order History</a>
420
- <a href="{{ url_for('logout') }}" class="dropdown-item">Logout</a>
421
- </div>
422
- </div>
423
-
424
-
425
-
426
- <!-- Category Filter with Custom Radio Buttons -->
427
- <form method="get" action="/menu" class="text-center mb-4">
428
- <label class="form-label fw-bold">Select a Category:</label>
429
- <div class="form-check form-check-inline">
430
- {% for category in categories %}
431
- <input type="radio" id="category-{{ category }}" name="category" value="{{ category }}" class="custom-radio"
432
- {% if selected_category == category %}checked{% endif %} onchange="this.form.submit()">
433
- <label class="form-check-label" for="category-{{ category }}">{{ category }}</label>
434
- {% endfor %}
435
- </div>
436
- <!-- Separate Customized Dish radio button in a new div to align it properly -->
437
- <div class="form-check">
438
- <input type="radio" id="category-CustomizedDish" name="category" value="Customized Dish" class="custom-radio"
439
- {% if selected_category == "Customized Dish" %}checked{% endif %} onchange="this.form.submit()">
440
- <label class="form-check-label" for="category-CustomizedDish">Customized Dish</label>
441
- </div>
442
- </form>
443
-
444
- <!-- Show menu items only when Customized Dish is not selected -->
445
- <div class="container mt-4">
446
- <h1 class="text-center">Menu</h1>
447
-
448
- <!-- Display text boxes for Customized Dish -->
449
- {% if selected_category == "Customized Dish" %}
450
- <div id="custom-dish-form" class="mt-4">
451
- <h3>Create Your Custom Dish</h3>
452
- <form method="POST" action="/generate_custom_dish">
453
- <div class="mb-3">
454
- <label for="custom-dish-name" class="form-label">Dish Name</label>
455
- <input type="text" class="form-control" id="custom-dish-name" name="name" required>
456
- </div>
457
- <div class="mb-3">
458
- <label for="custom-dish-description" class="form-label">Dish Description</label>
459
- <textarea class="form-control" id="custom-dish-description" name="description" required></textarea>
460
- </div>
461
- <button type="submit" class="btn btn-primary">Submit</button>
462
- </form>
463
- </div>
464
- {% else %}
465
-
466
- <!-- Menu Sections -->
467
- {% for section, items in ordered_menu.items() %}
468
- <h3>{{ section }}</h3>
469
- <div class="row">
470
- {% for item in items %}
471
- <div class="col-md-6 mb-4">
472
- <div class="card menu-card">
473
- <img src="{{ item.Image1__c }}" class="card-img-top menu-image" alt="{{ item.Name }}" onerror="this.src='/static/placeholder.jpg';">
474
- <div class="card-body">
475
- <h5 class="card-title">{{ item.Name }}</h5>
476
- <p class="card-text">${{ item.Price__c }}</p>
477
- <button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#itemModal"
478
- onclick="showItemDetails('{{ item.Name }}', '{{ item.Price__c }}', '{{ item.Image2__c }}', '{{ item.Description__c }}', '{{ item.Section__c }}','{{ selected_category }}')">
479
- Add
480
- </button>
481
- </div>
482
- </div>
483
  </div>
484
- {% endfor %}
485
- </div>
486
- {% endfor %}
487
- </div>
488
- {% endif %}
489
 
490
- </div>
 
 
 
 
 
491
 
492
- <!-- View Cart Button -->
493
- <div class="view-cart-container">
494
- <a href="/cart" class="view-cart-button">
495
- View Cart
496
- </a>
 
497
  </div>
498
 
499
- <!-- Modal for Item Details -->
500
- <div class="modal fade" id="itemModal" tabindex="-1" aria-labelledby="itemModalLabel" aria-hidden="true">
501
- <div class="modal-dialog modal-dialog-centered">
502
- <div class="modal-content">
503
- <div class="modal-header">
504
- <h5 class="modal-title" id="itemModalLabel">Item Details</h5>
505
- <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
506
- </div>
507
- <div class="modal-body">
508
- <!-- Item Image -->
509
- <img id="modal-img" class="img-fluid rounded mb-3 d-block mx-auto" alt="Item Image" style="max-height: 200px; object-fit: cover;">
510
- <!-- Item Name -->
511
- <h5 id="modal-name" class="fw-bold text-center"></h5>
512
- <!-- Item Price -->
513
- <p id="modal-price" class="text-muted text-center"></p>
514
- <!-- Item Description -->
515
- <p id="modal-description" class="text-secondary"></p>
516
- <!-- Add-ons -->
517
- <div id="modal-addons" class="modal-addons mt-4">
518
- <h6>Customization Options</h6>
519
- <div id="addons-list" class="addons-container">Loading customization options...</div>
520
- </div>
521
- <div class="mt-4">
522
- <h6>Custom Request</h6>
523
- <textarea id="modal-instructions" class="form-control" placeholder="Enter any special instructions here..."></textarea>
524
- </div>
525
- <span id="modal-section" data-section="" data-category="" style="display: none;"></span>
526
- </div>
527
- <!-- Quantity Controls and Add to Cart Button -->
528
- <div class="modal-footer d-flex align-items-center justify-content-between">
529
- <!-- Quantity Controls -->
530
- <div class="d-flex align-items-center gap-2">
531
- <button type="button" class="btn btn-outline-secondary" id="decreaseQuantity">-</button>
532
- <input type="text" class="form-control text-center" id="quantityInput" value="1" readonly style="width: 50px;"/>
533
- <button type="button" class="btn btn-outline-secondary" id="increaseQuantity">+</button>
534
- </div>
535
- <!-- Add to Cart Button -->
536
- <button type="button" class="btn btn-primary" onclick="addToCartFromModal()">Add to Cart</button>
537
- </div>
538
  </div>
539
  </div>
540
- </div>
541
 
542
- <!-- JavaScript -->
543
- <script>
544
- // Show item details and fetch customization options
545
- function showItemDetails(name, price, image, description, section, selectedCategory) {
546
- document.getElementById('modal-name').innerText = name;
547
- document.getElementById('modal-price').innerText = `$${price}`;
548
- document.getElementById('modal-img').src = image || '/static/placeholder.jpg';
549
- document.getElementById('modal-description').innerText = description || 'No description available.';
550
- document.getElementById('addons-list').innerHTML = 'Loading customization options...';
551
- document.getElementById('modal-instructions').value = '';
552
- const modalSectionEl = document.getElementById('modal-section');
553
- modalSectionEl.setAttribute('data-section', section);
554
- modalSectionEl.setAttribute('data-category', selectedCategory);
555
- // Set the default quantity to 1
556
- document.getElementById('quantityInput').value = 1;
557
-
558
- // Fetch customization options based on the section
559
- fetch(`/api/addons?item_name=${encodeURIComponent(name)}&item_section=${encodeURIComponent(section)}`)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
560
  .then(response => response.json())
561
  .then(data => {
562
- const addonsList = document.getElementById('addons-list');
563
- addonsList.innerHTML = ''; // Clear previous content
564
- if (!data.success || !data.addons || data.addons.length === 0) {
565
- addonsList.innerHTML = '<p>No customization options available.</p>';
566
- return;
567
- }
568
-
569
- // Display customization options inside styled divs
570
- data.addons.forEach(addon => {
571
- const sectionDiv = document.createElement('div');
572
- sectionDiv.classList.add('addon-section'); // Add styling class
573
-
574
- // Add section title
575
- const title = document.createElement('h6');
576
- title.innerText = addon.name;
577
- sectionDiv.appendChild(title);
578
-
579
- // Create options list
580
- const optionsContainer = document.createElement('div');
581
- addon.options.forEach((option, index) => {
582
- const optionId = `addon-${addon.name.replace(/\s+/g, '')}-${index}`;
583
- const listItem = document.createElement('div');
584
- listItem.classList.add('form-check');
585
- listItem.innerHTML = `
586
- <input type="checkbox" class="form-check-input addon-option" id="${optionId}" value="${option}"
587
- data-name="${option}" data-group="${addon.name}" data-price="${addon.extra_charge ? addon.extra_charge_amount : 0}">
588
- <label class="form-check-label" for="${optionId}">
589
- ${option} ${addon.extra_charge ? `($${addon.extra_charge_amount})` : ''}
590
- </label>
591
- `;
592
- optionsContainer.appendChild(listItem);
593
- });
594
- sectionDiv.appendChild(optionsContainer);
595
- addonsList.appendChild(sectionDiv);
596
- });
597
  })
598
- .catch(err => {
599
- console.error('Error fetching add-ons:', err);
600
- document.getElementById('addons-list').innerHTML = '<p>Error loading customization options.</p>';
601
  });
602
- }
603
- // Handle single-select/deselect logic for checkbox groups in all modals
604
- document.addEventListener('click', function(event) {
605
- if (event.target.classList.contains('addon-option')) {
606
- handleAddonClick(event.target);
607
  }
608
- });
609
- // Handle checkbox selection logic
610
- function handleAddonClick(checkbox) {
611
- const groupName = checkbox.getAttribute('data-group');
612
- const isMultiSelectGroup = ["Extra Toppings", "Choose Raita/Sides","Select Dip/Sauce","Extra Add-ons","Make it a Combo"].includes(groupName);
613
-
614
- // If it's not multi-select, uncheck all other checkboxes in the same group
615
- if (!isMultiSelectGroup) {
616
- const checkboxes = document.querySelectorAll(`.addon-option[data-group="${groupName}"]`);
617
- checkboxes.forEach(otherCheckbox => {
618
- if (otherCheckbox !== checkbox) {
619
- otherCheckbox.checked = false;
620
- }
621
- });
622
- }
623
- }
624
- function filterMenu() {
625
- let input = document.getElementById('searchBar').value.toLowerCase(); // Get the value from search bar
626
- let sections = document.querySelectorAll('h3'); // Select section headers
627
- let items = document.querySelectorAll('.menu-card'); // Select all items
628
- let matchedSections = new Set(); // Store matched sections
629
-
630
- // Hide all items initially
631
- items.forEach(item => {
632
- let itemName = item.querySelector('.card-title').innerText.toLowerCase(); // Get item name
633
- let itemSection = item.closest('.row').previousElementSibling.innerText.toLowerCase(); // Get section name
634
-
635
- // If the search matches item name or section, show the item
636
- if (itemName.includes(input) || (itemSection && itemSection.includes(input))) {
637
- item.style.display = 'block'; // Show item if it matches search
638
- matchedSections.add(item.closest('.row')); // Add section to matched list
639
- } else {
640
- item.style.display = 'none'; // Hide item if not matched
641
- }
642
- });
643
-
644
- // Show or hide sections based on matched items
645
- sections.forEach(section => {
646
- let sectionRow = section.nextElementSibling; // The row containing items
647
- if (matchedSections.has(sectionRow)) {
648
- section.style.display = 'block'; // Show section header
649
- sectionRow.style.display = 'flex'; // Show section items
650
- } else {
651
- section.style.display = 'none'; // Hide section header
652
- sectionRow.style.display = 'none'; // Hide section items
653
- }
654
- });
655
- }
656
- function addToCartFromModal() {
657
- const itemName = document.getElementById('modal-name').innerText;
658
- let itemPrice = parseFloat(document.getElementById('modal-price').innerText.replace('$', ''));
659
- // Validate item price
660
- if (isNaN(itemPrice)) {
661
- alert('Invalid price for the item. Please check the item details.');
662
- return;
663
- }
664
- const itemImage = document.getElementById('modal-img').src;
665
- console.log(itemName, itemPrice, itemImage); // Log values for debugging
666
- const modalSectionEl = document.getElementById('modal-section');
667
- const section = modalSectionEl.getAttribute('data-section');
668
- const selectedCategory = modalSectionEl.getAttribute('data-category');
669
- if (!itemName || !itemPrice || !section || !itemImage) {
670
- console.error('Missing data for cart item:', { itemName, itemPrice, section, itemImage});
671
- return;
672
- }
673
-
674
- // Collect selected add-ons
675
- let selectedAddOns = Array.from(
676
- document.querySelectorAll('#addons-list input[type="checkbox"]:checked')
677
- ).map(addon => ({
678
- name: addon.getAttribute('data-name') || 'Default Name', // Fallback Name
679
- price: parseFloat(addon.getAttribute('data-price') || 0)
680
- }));
681
- // Get the selected quantity
682
- const quantity = parseInt(document.getElementById('quantityInput').value) || 1; // Default to 1 if invalid
683
- const instructions = document.getElementById('modal-instructions').value;
684
- // Prepare data for the cart
685
- const cartPayload = {
686
- itemName: itemName,
687
- itemPrice: itemPrice,
688
- itemImage: itemImage,
689
- section: section,
690
- category: selectedCategory,
691
- addons: selectedAddOns,
692
- instructions: instructions,
693
- quantity: quantity // Include the quantity
694
- };
695
- // Send the cart data to the server
696
- fetch('/cart/add', {
697
- method: 'POST',
698
- headers: {
699
- 'Content-Type': 'application/json',
700
- },
701
- body: JSON.stringify(cartPayload)
702
- })
703
- .then(response => response.json())
704
- .then(data => {
705
- if (data.success) {
706
- alert('Item added to cart successfully!');
707
- updateCartUI(data.cart); // Update cart UI after adding an item
708
- const modal = document.getElementById('itemModal');
709
- const modalInstance = bootstrap.Modal.getInstance(modal);
710
- modalInstance.hide();
711
- } else {
712
- alert(data.error || 'Failed to add item to cart.');
713
- }
714
- })
715
- .catch(err => {
716
- console.error('Error adding item to cart:', err);
717
- alert('An error occurred while adding the item to the cart.');
718
- });
719
- }
720
- function updateCartUI(cart) {
721
- if (!Array.isArray(cart)) {
722
- console.error('Invalid cart data:', cart);
723
- return;
724
- }
725
- const cartIcon = document.getElementById('cart-icon');
726
- cartIcon.innerText = cart.length; // Assuming cart is an array of items
727
- }
728
- function updateCartDisplay(cart) {
729
- if (!Array.isArray(cart)) {
730
- console.error('Invalid cart data:', cart);
731
- return;
732
- }
733
- // Optional: Update quantity on the cart page
734
- const cartCountElement = document.getElementById('cart-count');
735
- cartCountElement.innerText = cart.reduce((total, item)=> total+item.quantity,0); // Update cart item count //Sum of all quantities
736
-
737
- // Optionally, show a small success notification that the item was added
738
- const successNotification = document.createElement('div');
739
- successNotification.classList.add('success-notification');
740
- successNotification.innerText = 'Item added to cart!';
741
- document.body.appendChild(successNotification);
742
- setTimeout(() => {
743
- successNotification.remove(); // Remove success notification after a few seconds
744
- }, 2000);
745
- }
746
-
747
- document.addEventListener('DOMContentLoaded', function () {
748
- // Get references to the quantity buttons and the input field
749
- const decreaseBtn = document.getElementById('decreaseQuantity');
750
- const increaseBtn = document.getElementById('increaseQuantity');
751
- const quantityInput = document.getElementById('quantityInput');
752
- // Add event listener to decrease button
753
- decreaseBtn.addEventListener('click', function () {
754
- let currentQuantity = parseInt(quantityInput.value);
755
- if (currentQuantity > 1) {
756
- currentQuantity--;
757
- quantityInput.value = currentQuantity;
758
- }
759
- });
760
- // Add event listener to increase button
761
- increaseBtn.addEventListener('click', function () {
762
- let currentQuantity = parseInt(quantityInput.value);
763
- currentQuantity++;
764
- quantityInput.value = currentQuantity;
765
- });
766
- });
767
- // Function to round reward points to a single digit
768
- function roundRewardPoints() {
769
- // Get the reward points element
770
- let rewardPointsElement = document.getElementById('reward-points');
771
- // Check if the element exists in the DOM
772
- if (rewardPointsElement) {
773
- let rewardPointsText = rewardPointsElement.innerText.trim(); // Get and trim the value to remove any extra spaces
774
- // Check if the innerText is a valid number
775
- let rewardPoints = parseFloat(rewardPointsText);
776
- // If it's a valid number, round it to 1 decimal place
777
- if (!isNaN(rewardPoints)) {
778
- rewardPointsElement.innerText = rewardPoints.toFixed(1); // Round to 1 decimal place
779
- } else {
780
- console.error("Reward points value is not a valid number:", rewardPointsText);
781
  }
782
- } else {
783
- console.error("Reward points element is missing.");
784
- }
785
- }
786
- // Run the function when the page loads
787
- window.onload = roundRewardPoints;
788
-
789
  </script>
790
 
791
- <!-- Bootstrap JS -->
792
- <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
793
  </body>
794
- </html>
 
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
+ header {
17
+ background-color: #333;
18
+ color: white;
19
+ padding: 15px;
20
+ text-align: center;
21
+ }
22
+ .menu-container {
23
+ margin: 20px;
24
+ }
25
+ .menu-category {
26
+ margin-bottom: 20px;
27
+ }
28
+ .menu-category h2 {
29
+ text-align: center;
30
+ font-size: 24px;
31
+ }
32
+ .menu-item {
33
+ background-color: white;
34
+ padding: 10px;
35
+ margin-bottom: 10px;
36
+ border-radius: 5px;
37
+ box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1);
38
+ display: flex;
39
+ justify-content: space-between;
40
+ align-items: center;
41
+ }
42
+ .menu-item h3 {
43
+ margin: 0;
44
+ font-size: 20px;
45
+ }
46
+ .menu-item p {
47
+ margin: 0;
48
+ font-size: 16px;
49
+ color: #888;
50
+ }
51
+ .menu-item button {
52
+ padding: 8px 12px;
53
+ background-color: #28a745;
54
+ color: white;
55
+ border: none;
56
+ border-radius: 5px;
57
+ cursor: pointer;
58
+ }
59
+ .menu-item button:hover {
60
+ background-color: #218838;
61
+ }
62
+ .cart-button {
63
+ padding: 12px 20px;
64
+ background-color: #007bff;
65
+ color: white;
66
+ border: none;
67
+ border-radius: 5px;
68
+ text-align: center;
69
+ font-size: 18px;
70
+ cursor: pointer;
71
+ width: 100%;
72
+ }
73
+ .cart-button:hover {
74
+ background-color: #0056b3;
75
+ }
76
+ .cart-icon {
77
+ margin-right: 8px;
78
+ }
79
+ footer {
80
+ text-align: center;
81
+ padding: 10px;
82
+ background-color: #333;
83
+ color: white;
84
+ position: fixed;
85
+ width: 100%;
86
+ bottom: 0;
87
+ }
88
+ .order-summary {
89
+ margin: 20px;
90
+ padding: 20px;
91
+ background-color: white;
92
+ border-radius: 5px;
93
+ box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1);
94
+ }
95
+ .order-summary h3 {
96
+ font-size: 24px;
97
+ text-align: center;
98
+ }
99
+ .order-summary ul {
100
+ list-style-type: none;
101
+ padding: 0;
102
+ }
103
+ .order-summary li {
104
+ padding: 10px;
105
+ border-bottom: 1px solid #ddd;
106
+ display: flex;
107
+ justify-content: space-between;
108
+ }
109
+ .order-summary button {
110
+ padding: 10px 20px;
111
+ background-color: #007bff;
112
+ color: white;
113
+ border: none;
114
+ border-radius: 5px;
115
+ font-size: 18px;
116
+ cursor: pointer;
117
+ }
118
+ .order-summary button:hover {
119
+ background-color: #0056b3;
120
+ }
121
+ .cart-summary {
122
+ display: flex;
123
+ justify-content: space-between;
124
+ margin-top: 20px;
125
+ }
126
+ .cart-summary span {
127
+ font-size: 18px;
128
+ font-weight: bold;
129
+ }
130
+ .cart-summary button {
131
+ background-color: #28a745;
132
+ }
133
+ .logout-button {
134
+ padding: 12px 20px;
135
+ background-color: #dc3545;
136
+ color: white;
137
+ border: none;
138
+ border-radius: 5px;
139
+ font-size: 18px;
140
+ cursor: pointer;
141
+ width: 100%;
142
+ margin-top: 20px;
143
+ }
144
+ .logout-button:hover {
145
+ background-color: #c82333;
146
+ }
147
+ </style>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  </head>
149
  <body>
 
 
 
 
 
150
 
151
+ <!-- Header -->
152
+ <header>
153
+ <h1>Welcome to Our Restaurant</h1>
154
+ </header>
155
 
156
+ <!-- Menu Content -->
157
+ <div class="menu-container">
158
+ <!-- Main Course Category -->
159
+ <div class="menu-category">
160
+ <h2>Main Course</h2>
161
+ {% for item in menu_items %}
162
+ <div class="menu-item">
163
+ <div>
164
+ <h3>{{ item.name }}</h3>
165
+ <p>Price: {{ item.price }}</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
  </div>
167
+ <button onclick="addToCart('{{ item.name }}', {{ item.price }}, '{{ item.category }}')">Add to Cart</button>
168
+ </div>
169
+ {% endfor %}
170
+ </div>
 
171
 
172
+ <!-- Cart Button -->
173
+ <div class="menu-category">
174
+ <button class="cart-button" onclick="showCart()">
175
+ <i class="fas fa-shopping-cart cart-icon"></i> View Cart
176
+ </button>
177
+ </div>
178
 
179
+ <!-- Logout Button -->
180
+ <div class="menu-category">
181
+ <button class="logout-button" onclick="logout()">
182
+ <i class="fas fa-sign-out-alt cart-icon"></i> Logout
183
+ </button>
184
+ </div>
185
  </div>
186
 
187
+ <!-- Cart Summary (hidden initially) -->
188
+ <div id="cart-summary" class="order-summary" style="display:none;">
189
+ <h3>Your Cart</h3>
190
+ <ul id="cart-items-list">
191
+ <!-- Cart items will be dynamically listed here -->
192
+ </ul>
193
+ <div class="cart-summary">
194
+ <span>Total: ₹<span id="total-price">0</span></span>
195
+ <button onclick="placeOrder()">Place Order</button>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
  </div>
197
  </div>
 
198
 
199
+ <!-- Footer -->
200
+ <footer>
201
+ <p>Restaurant &copy; 2025</p>
202
+ </footer>
203
+
204
+ <!-- JavaScript -->
205
+ <script>
206
+ let cart = [];
207
+ // Add item to cart
208
+ function addToCart(itemName, itemPrice, itemCategory) {
209
+ cart.push({ name: itemName, price: itemPrice, category: itemCategory });
210
+ alert(`${itemName} added to cart!`);
211
+ }
212
+ // Show cart and order summary
213
+ function showCart() {
214
+ if (cart.length === 0) {
215
+ alert("Your cart is empty!");
216
+ return;
217
+ }
218
+ // Update cart items list
219
+ const cartItemsList = document.getElementById('cart-items-list');
220
+ cartItemsList.innerHTML = '';
221
+ let totalPrice = 0;
222
+ cart.forEach(item => {
223
+ const li = document.createElement('li');
224
+ li.innerHTML = `${item.name} - ₹${item.price}`;
225
+ cartItemsList.appendChild(li);
226
+ totalPrice += item.price;
227
+ });
228
+ // Update total price
229
+ document.getElementById('total-price').textContent = totalPrice;
230
+ // Show cart summary
231
+ document.getElementById('cart-summary').style.display = 'block';
232
+ }
233
+ // Place the order
234
+ function placeOrder() {
235
+ if (cart.length === 0) {
236
+ alert("Your cart is empty, cannot place the order.");
237
+ return;
238
+ }
239
+ // Send the order to the backend (POST request)
240
+ fetch('/order', {
241
+ method: 'POST',
242
+ headers: {
243
+ 'Content-Type': 'application/json',
244
+ },
245
+ body: JSON.stringify({
246
+ customer_id: "user-id-placeholder", // Replace with actual user ID if necessary
247
+ items: cart.map(item => ({
248
+ item_id: item.name,
249
+ quantity: 1, // Assuming quantity is 1 for now
250
+ }))
251
+ })
252
+ })
253
  .then(response => response.json())
254
  .then(data => {
255
+ alert(data.message);
256
+ cart = []; // Clear cart after placing the order
257
+ document.getElementById('cart-summary').style.display = 'none'; // Hide cart summary
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
  })
259
+ .catch(error => {
260
+ console.error('Error:', error);
261
+ alert('Error placing order');
262
  });
 
 
 
 
 
263
  }
264
+ // Logout
265
+ function logout() {
266
+ fetch('/logout')
267
+ .then(response => {
268
+ window.location.href = "/"; // Redirect to home page after logout
269
+ })
270
+ .catch(error => {
271
+ console.error('Error:', error);
272
+ alert('Error logging out');
273
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
274
  }
 
 
 
 
 
 
 
275
  </script>
276
 
 
 
277
  </body>
278
+ </html>